Commit 6957e1ac authored by Oliver Neukum's avatar Oliver Neukum Committed by Greg Kroah-Hartman

USB: fix needless failure under certain conditions

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: default avatarOliver Neukum <oneukum@suse.de>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent c5999f0d
...@@ -604,10 +604,6 @@ static unsigned int usb_device_poll(struct file *file, struct poll_table_struct ...@@ -604,10 +604,6 @@ static unsigned int usb_device_poll(struct file *file, struct poll_table_struct
lock_kernel(); lock_kernel();
if (!st) { if (!st) {
st = kmalloc(sizeof(struct usb_device_status), GFP_KERNEL); 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 */ /* we may have dropped BKL - need to check for having lost the race */
if (file->private_data) { if (file->private_data) {
...@@ -615,6 +611,11 @@ static unsigned int usb_device_poll(struct file *file, struct poll_table_struct ...@@ -615,6 +611,11 @@ static unsigned int usb_device_poll(struct file *file, struct poll_table_struct
st = file->private_data; st = file->private_data;
goto lost_race; 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 * need to prevent the module from being unloaded, since
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment