diff options
| author | Alan Stern <[email protected]> | 2008-06-24 18:47:29 +0000 |
|---|---|---|
| committer | Greg Kroah-Hartman <[email protected]> | 2008-07-21 22:16:43 +0000 |
| commit | e04199b2167e88f0e2d0410fafaa2c35ff7ba8c1 (patch) | |
| tree | d09cdcd85bfa3ead3d63cf6e1c1b6454fc4ee7f0 /drivers/usb/core/devio.c | |
| parent | usbfs: fix race between open and unregister (diff) | |
| download | kernel-e04199b2167e88f0e2d0410fafaa2c35ff7ba8c1.tar.gz kernel-e04199b2167e88f0e2d0410fafaa2c35ff7ba8c1.zip | |
usbfs: don't store bad pointers in registration
This patch (as1107) fixes a small bug in the usbfs registration and
unregistration code. It avoids leaving an error value stored in the
device's usb_classdev field and it avoids trying to unregister a NULL
pointer. (It also fixes a rather extreme overuse of whitespace.)
Signed-off-by: Alan Stern <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
Diffstat (limited to 'drivers/usb/core/devio.c')
| -rw-r--r-- | drivers/usb/core/devio.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c index c44e98f6099e..5580c6e59bae 100644 --- a/drivers/usb/core/devio.c +++ b/drivers/usb/core/devio.c @@ -1726,20 +1726,21 @@ static struct class *usb_classdev_class; static int usb_classdev_add(struct usb_device *dev) { - int minor = ((dev->bus->busnum-1) * 128) + (dev->devnum-1); - - dev->usb_classdev = device_create(usb_classdev_class, &dev->dev, - MKDEV(USB_DEVICE_MAJOR, minor), - "usbdev%d.%d", dev->bus->busnum, dev->devnum); - if (IS_ERR(dev->usb_classdev)) - return PTR_ERR(dev->usb_classdev); + struct device *cldev; + cldev = device_create(usb_classdev_class, &dev->dev, dev->dev.devt, + "usbdev%d.%d", dev->bus->busnum, + dev->devnum); + if (IS_ERR(cldev)) + return PTR_ERR(cldev); + dev->usb_classdev = cldev; return 0; } static void usb_classdev_remove(struct usb_device *dev) { - device_unregister(dev->usb_classdev); + if (dev->usb_classdev) + device_unregister(dev->usb_classdev); usb_fs_classdev_common_remove(dev); } |
