From oneukum@suse.de Thu Jan 25 02:22:26 2007 From: Oliver Neukum Date: Thu, 25 Jan 2007 11:22:24 +0100 Subject: USB: fix needless failure under certain conditions To: gregkh@suse.de, linux-usb-devel@lists.sourceforge.net Message-ID: <200701251122.24437.oneukum@suse.de> Content-Disposition: inline in devices.c we have a piece of code for dealing with losing in a race. If we indeed lose the race we don't care whether our own memory allocation worked. The check for that is so early that we return early even if we don't have to. Signed-off-by: Oliver Neukum Signed-off-by: Greg Kroah-Hartman ---- --- drivers/usb/core/devices.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) --- gregkh-2.6.orig/drivers/usb/core/devices.c +++ gregkh-2.6/drivers/usb/core/devices.c @@ -604,10 +604,6 @@ static unsigned int usb_device_poll(stru lock_kernel(); if (!st) { st = kmalloc(sizeof(struct usb_device_status), GFP_KERNEL); - if (!st) { - unlock_kernel(); - return POLLIN; - } /* we may have dropped BKL - need to check for having lost the race */ if (file->private_data) { @@ -615,6 +611,11 @@ static unsigned int usb_device_poll(stru st = file->private_data; goto lost_race; } + /* we haven't lost - check for allocation failure now */ + if (!st) { + unlock_kernel(); + return POLLIN; + } /* * need to prevent the module from being unloaded, since