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

[PATCH] USB usbfs: fix race between disconnect and usbdev_open

parent ababa0cf
......@@ -484,14 +484,17 @@ static int usbdev_open(struct inode *inode, struct file *file)
* and the hub thread have the kernel lock
* (still acquire the kernel lock for safety)
*/
ret = -ENOMEM;
if (!(ps = kmalloc(sizeof(struct dev_state), GFP_KERNEL)))
goto out_nolock;
lock_kernel();
ret = -ENOENT;
dev = inode->u.generic_ip;
if (!dev)
goto out;
ret = -ENOMEM;
if (!(ps = kmalloc(sizeof(struct dev_state), GFP_KERNEL)))
if (!dev) {
kfree(ps);
goto out;
}
ret = 0;
ps->dev = dev;
ps->file = file;
......@@ -509,6 +512,7 @@ static int usbdev_open(struct inode *inode, struct file *file)
file->private_data = ps;
out:
unlock_kernel();
out_nolock:
return ret;
}
......
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