Skip to content

Commit

Permalink
USB: fix needless failure under certain conditions
Browse files Browse the repository at this point in the history
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 <oneukum@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Oliver Neukum authored and Greg Kroah-Hartman committed Feb 16, 2007
1 parent c5999f0 commit 6957e1a
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions drivers/usb/core/devices.c
Original file line number Diff line number Diff line change
Expand Up @@ -604,17 +604,18 @@ static unsigned int usb_device_poll(struct file *file, struct poll_table_struct
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) {
kfree(st);
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
Expand Down

0 comments on commit 6957e1a

Please sign in to comment.