diff options
author | Alan Stern <stern@rowland.harvard.edu> | 2008-06-24 14:47:29 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2008-07-21 18:16:43 -0400 |
commit | e04199b2167e88f0e2d0410fafaa2c35ff7ba8c1 (patch) | |
tree | d09cdcd85bfa3ead3d63cf6e1c1b6454fc4ee7f0 /drivers/usb | |
parent | d64aac36394b3c26db53538bfedd8444a3a2206e (diff) |
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 <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb')
-rw-r--r-- | drivers/usb/core/devio.c | 19 |
1 files changed, 10 insertions, 9 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; | |||
1726 | 1726 | ||
1727 | static int usb_classdev_add(struct usb_device *dev) | 1727 | static int usb_classdev_add(struct usb_device *dev) |
1728 | { | 1728 | { |
1729 | int minor = ((dev->bus->busnum-1) * 128) + (dev->devnum-1); | 1729 | struct device *cldev; |
1730 | 1730 | ||
1731 | dev->usb_classdev = device_create(usb_classdev_class, &dev->dev, | 1731 | cldev = device_create(usb_classdev_class, &dev->dev, dev->dev.devt, |
1732 | MKDEV(USB_DEVICE_MAJOR, minor), | 1732 | "usbdev%d.%d", dev->bus->busnum, |
1733 | "usbdev%d.%d", dev->bus->busnum, dev->devnum); | 1733 | dev->devnum); |
1734 | if (IS_ERR(dev->usb_classdev)) | 1734 | if (IS_ERR(cldev)) |
1735 | return PTR_ERR(dev->usb_classdev); | 1735 | return PTR_ERR(cldev); |
1736 | 1736 | dev->usb_classdev = cldev; | |
1737 | return 0; | 1737 | return 0; |
1738 | } | 1738 | } |
1739 | 1739 | ||
1740 | static void usb_classdev_remove(struct usb_device *dev) | 1740 | static void usb_classdev_remove(struct usb_device *dev) |
1741 | { | 1741 | { |
1742 | device_unregister(dev->usb_classdev); | 1742 | if (dev->usb_classdev) |
1743 | device_unregister(dev->usb_classdev); | ||
1743 | usb_fs_classdev_common_remove(dev); | 1744 | usb_fs_classdev_common_remove(dev); |
1744 | } | 1745 | } |
1745 | 1746 | ||