Skip to content

Commit

Permalink
usb devio: handle class_device_create() error
Browse files Browse the repository at this point in the history
This patch adds missing class_device_create() error check,
and makes notifier return NOTIFY_BAD.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Akinobu Mita authored and Greg Kroah-Hartman committed Oct 17, 2006
1 parent f8ac232 commit 27d39e2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions drivers/usb/core/devio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1588,15 +1588,18 @@ const struct file_operations usbfs_device_file_operations = {
.release = usbdev_release,
};

static void usbdev_add(struct usb_device *dev)
static int usbdev_add(struct usb_device *dev)
{
int minor = ((dev->bus->busnum-1) * 128) + (dev->devnum-1);

dev->class_dev = class_device_create(usb_device_class, NULL,
MKDEV(USB_DEVICE_MAJOR, minor), &dev->dev,
"usbdev%d.%d", dev->bus->busnum, dev->devnum);
if (IS_ERR(dev->class_dev))
return PTR_ERR(dev->class_dev);

dev->class_dev->class_data = dev;
return 0;
}

static void usbdev_remove(struct usb_device *dev)
Expand All @@ -1609,7 +1612,8 @@ static int usbdev_notify(struct notifier_block *self, unsigned long action,
{
switch (action) {
case USB_DEVICE_ADD:
usbdev_add(dev);
if (usbdev_add(dev))
return NOTIFY_BAD;
break;
case USB_DEVICE_REMOVE:
usbdev_remove(dev);
Expand Down

0 comments on commit 27d39e2

Please sign in to comment.