lkml.org 
[lkml]   [2016]   [May]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: UBSAN whinge in ihci-hub.c
From
2016-05-18 17:40 GMT+03:00 Alan Stern <stern@rowland.harvard.edu>:

> All right, I'm getting very tired of all these bug reports. Besides,
> Andrey has a point: Unless you're Linus, arguing against the C standard
> is futile. (Even though the language dialect used in the kernel is not
> standard C.)
>
> Does this patch make UBSAN happy? The runtime overhead is minimal.
>

It does. However, you could fool ubsan way more easy:
u32 __iomem *hostpc_reg = ehci->regs->hostpc +
(wIndex & 0xff) - 1;



> Alan Stern
>
>
>
> Index: usb-4.x/drivers/usb/host/ehci-hub.c
> ===================================================================
> --- usb-4.x.orig/drivers/usb/host/ehci-hub.c
> +++ usb-4.x/drivers/usb/host/ehci-hub.c
> @@ -872,14 +872,17 @@ int ehci_hub_control(
> ) {
> struct ehci_hcd *ehci = hcd_to_ehci (hcd);
> int ports = HCS_N_PORTS (ehci->hcs_params);
> - u32 __iomem *status_reg = &ehci->regs->port_status[
> - (wIndex & 0xff) - 1];
> - u32 __iomem *hostpc_reg = &ehci->regs->hostpc[(wIndex & 0xff) - 1];
> + u32 __iomem *status_reg, *hostpc_reg;
> u32 temp, temp1, status;
> unsigned long flags;
> int retval = 0;
> unsigned selector;
>
> + temp = wIndex & 0xff;
> + temp -= (temp > 0);
> + status_reg = &ehci->regs->port_status[temp];
> + hostpc_reg = &ehci->regs->hostpc[temp];
> +
> /*
> * FIXME: support SetPortFeatures USB_PORT_FEAT_INDICATOR.
> * HCS_INDICATOR may say we can change LEDs to off/amber/green.
>

\
 
 \ /
  Last update: 2016-05-18 17:41    [W:0.143 / U:0.012 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site