All of lore.kernel.org
 help / color / mirror / Atom feed
From: akinobu.mita@gmail.com (Akinobu Mita)
To: linux-kernel@vger.kernel.org, linux-usb-devel@lists.sourceforge.net
Cc: Greg Kroah-Hartman <gregkh@suse.de>
Subject: [PATCH] usb devio: handle class_device_create() error
Date: Mon, 9 Oct 2006 18:09:33 +0900	[thread overview]
Message-ID: <20061009090933.GA6325@localhost> (raw)

This patch adds missing class_device_create() error check,
and makes notifier return NOTIFY_BAD.

Cc: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>

 drivers/usb/core/devio.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Index: work-fault-inject/drivers/usb/core/devio.c
===================================================================
--- work-fault-inject.orig/drivers/usb/core/devio.c	2006-10-09 15:06:27.000000000 +0900
+++ work-fault-inject/drivers/usb/core/devio.c	2006-10-09 15:09:23.000000000 +0900
@@ -1588,15 +1588,18 @@ const struct file_operations usbfs_devic
 	.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)
@@ -1609,7 +1612,8 @@ static int usbdev_notify(struct notifier
 {
 	switch (action) {
 	case USB_DEVICE_ADD:
-		usbdev_add(dev);
+		if (usbdev_add(dev))
+			return NOTIFY_BAD;
 		break;
 	case USB_DEVICE_REMOVE:
 		usbdev_remove(dev);

                 reply	other threads:[~2006-10-09  9:09 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20061009090933.GA6325@localhost \
    --to=akinobu.mita@gmail.com \
    --cc=gregkh@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb-devel@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.