Commit e04199b2 authored by Alan Stern's avatar Alan Stern Committed by Greg Kroah-Hartman

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: default avatarAlan Stern <stern@rowland.harvard.edu>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent d64aac36
...@@ -1726,20 +1726,21 @@ static struct class *usb_classdev_class; ...@@ -1726,20 +1726,21 @@ static struct class *usb_classdev_class;
static int usb_classdev_add(struct usb_device *dev) static int usb_classdev_add(struct usb_device *dev)
{ {
int minor = ((dev->bus->busnum-1) * 128) + (dev->devnum-1); struct device *cldev;
dev->usb_classdev = device_create(usb_classdev_class, &dev->dev, cldev = device_create(usb_classdev_class, &dev->dev, dev->dev.devt,
MKDEV(USB_DEVICE_MAJOR, minor), "usbdev%d.%d", dev->bus->busnum,
"usbdev%d.%d", dev->bus->busnum, dev->devnum); dev->devnum);
if (IS_ERR(dev->usb_classdev)) if (IS_ERR(cldev))
return PTR_ERR(dev->usb_classdev); return PTR_ERR(cldev);
dev->usb_classdev = cldev;
return 0; return 0;
} }
static void usb_classdev_remove(struct usb_device *dev) 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); usb_fs_classdev_common_remove(dev);
} }
......
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