lkml.org 
[lkml]   [2013]   [Mar]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] usb/core/devio.c: Don't use GFP_KERNEL while we cannot reset a storage device
On Mon, 11 Mar 2013, Ming Lei wrote:

> On Sat, Mar 9, 2013 at 12:50 AM, Alexey Khoroshilov
> <khoroshilov@ispras.ru> wrote:
> > As it was described by Oliver Neukum in commit acbe2fe
> > "USB: Don't use GFP_KERNEL while we cannot reset a storage device":
> >
> > Memory allocations with GFP_KERNEL can cause IO to a storage device
> > which can fail resulting in a need to reset the device. Therefore
> > GFP_KERNEL cannot be safely used between usb_lock_device()
> > and usb_unlock_device(). Replace by GFP_NOIO.
> >
> > The patch fixes the same issue in usb/core/devio.c.
> > All the allocations fixed are under usb_lock_device() from usbdev_do_ioctl().
>
> I am wondering why the device lock is needed for usbdev_do_ioctl()? Looks
> device lock isn't required for USB transfer of kernel driver.

Of course you have to lock the device before changing its driver. What
would happen if two different threads tried to change a device's driver
at the same time?

usbdev_do_ioctl() needs to acquire the device lock in order to prevent
races with driver_disconnect() and usbdev_remove().

Alan Stern



\
 
 \ /
  Last update: 2013-03-11 17:01    [W:0.122 / U:0.972 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site