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