Re: [PATCH v2] usb/core: usb_alloc_dev(): fix setting of ->portnum

2016-03-20 Thread Peter Chen
On Fri, Mar 18, 2016 at 10:13:34AM -0400, Alan Stern wrote:
> On Thu, 17 Mar 2016, Nicolai Stange wrote:
> 
> > With commit 69bec7259853 ("USB: core: let USB device know device node"),
> > the port1 argument of usb_alloc_dev() gets overwritten as follows:
> > 
> >   ... usb_alloc_dev(..., unsigned port1)
> >   {
> > ...
> > if (!parent->parent) {
> >   port1 = usb_hcd_find_raw_port_number(..., port1);
> > }
> > ...
> >   }
> > 
> > Later on, this now overwritten port1 gets assigned to ->portnum:
> > 
> >   dev->portnum = port1;
> > 
> > However, since xhci_find_raw_port_number() isn't idempotent, the
> > aforementioned commit causes a number of KASAN splats like the following:
> 
> ...
> 
> > Fix this by not overwriting the port1 argument in usb_alloc_dev(), but
> > storing the raw port number as required by OF in an additional variable,
> > raw_port.
> > 
> > Fixes: 69bec7259853 ("USB: core: let USB device know device node")
> > Signed-off-by: Nicolai Stange 
> > ---
> >  Applicable to linux-next-20160317
> > 
> >  Changes to v1:
> >  - Initialize raw_port with port1
> 
> Acked-by: Alan Stern 
> 

Thanks for fixing it in time, you are right. My patch would let the
device logical port number equals to device raw port number, but it
is wrong for xhci.

-- 

Best Regards,
Peter Chen
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2] usb/core: usb_alloc_dev(): fix setting of ->portnum

2016-03-19 Thread Alan Stern
On Thu, 17 Mar 2016, Nicolai Stange wrote:

> With commit 69bec7259853 ("USB: core: let USB device know device node"),
> the port1 argument of usb_alloc_dev() gets overwritten as follows:
> 
>   ... usb_alloc_dev(..., unsigned port1)
>   {
> ...
> if (!parent->parent) {
>   port1 = usb_hcd_find_raw_port_number(..., port1);
> }
> ...
>   }
> 
> Later on, this now overwritten port1 gets assigned to ->portnum:
> 
>   dev->portnum = port1;
> 
> However, since xhci_find_raw_port_number() isn't idempotent, the
> aforementioned commit causes a number of KASAN splats like the following:

...

> Fix this by not overwriting the port1 argument in usb_alloc_dev(), but
> storing the raw port number as required by OF in an additional variable,
> raw_port.
> 
> Fixes: 69bec7259853 ("USB: core: let USB device know device node")
> Signed-off-by: Nicolai Stange 
> ---
>  Applicable to linux-next-20160317
> 
>  Changes to v1:
>  - Initialize raw_port with port1

Acked-by: Alan Stern 

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html