public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Driver Core update for 2.6.4-rc1
Date: Tue, 2 Mar 2004 20:16:38 -0800	[thread overview]
Message-ID: <107828739888@kroah.com> (raw)
In-Reply-To: <10782873972560@kroah.com>

ChangeSet 1.1557.72.2, 2004/02/19 15:38:41-08:00, shemminger@osdl.org

[PATCH] propogate errors from misc_register to caller

The patch to check for / in class_device is not enough.
The misc_register function needs to check return value of the things it calls!


 drivers/char/misc.c |   24 +++++++++++++++++++-----
 1 files changed, 19 insertions(+), 5 deletions(-)


diff -Nru a/drivers/char/misc.c b/drivers/char/misc.c
--- a/drivers/char/misc.c	Tue Mar  2 19:52:14 2004
+++ b/drivers/char/misc.c	Tue Mar  2 19:52:14 2004
@@ -212,6 +212,9 @@
 int misc_register(struct miscdevice * misc)
 {
 	struct miscdevice *c;
+	struct class_device *class;
+	dev_t dev;
+	int err;
 	
 	down(&misc_sem);
 	list_for_each_entry(c, &misc_list, list) {
@@ -240,19 +243,30 @@
 		snprintf(misc->devfs_name, sizeof(misc->devfs_name),
 				"misc/%s", misc->name);
 	}
+	dev = MKDEV(MISC_MAJOR, misc->minor);
 
-	class_simple_device_add(misc_class, MKDEV(MISC_MAJOR, misc->minor),
-				misc->dev, misc->name);
-	devfs_mk_cdev(MKDEV(MISC_MAJOR, misc->minor),
-			S_IFCHR|S_IRUSR|S_IWUSR|S_IRGRP, misc->devfs_name);
+	class = class_simple_device_add(misc_class, dev,
+					misc->dev, misc->name);
+	if (IS_ERR(class)) {
+		err = PTR_ERR(class);
+		goto out;
+	}
+
+	err = devfs_mk_cdev(dev, S_IFCHR|S_IRUSR|S_IWUSR|S_IRGRP, 
+			    misc->devfs_name);
+	if (err) {
+		class_simple_device_remove(dev);
+		goto out;
+	}
 
 	/*
 	 * Add it to the front, so that later devices can "override"
 	 * earlier defaults
 	 */
 	list_add(&misc->list, &misc_list);
+ out:
 	up(&misc_sem);
-	return 0;
+	return err;
 }
 
 /**


  reply	other threads:[~2004-03-03  4:52 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-03-03  4:14 [BK PATCH] Driver Core update for 2.6.4-rc1 Greg KH
2004-03-03  4:16 ` [PATCH] " Greg KH
2004-03-03  4:16   ` Greg KH [this message]
2004-03-03  4:16     ` Greg KH
2004-03-03  4:16       ` Greg KH
2004-03-03  4:16         ` Greg KH
2004-03-03  4:16           ` Greg KH
2004-03-03  4:16             ` Greg KH
2004-03-03  4:16               ` Greg KH
2004-03-03  4:16                 ` Greg KH
2004-03-03  4:16                   ` Greg KH
2004-03-03 22:24                     ` Russell King
2004-03-03 23:06                       ` Greg KH
2004-03-03  8:00             ` Christoph Hellwig
2004-03-03 15:07               ` Greg KH
2004-03-03 15:13                 ` Christoph Hellwig
2004-03-03 15:19                   ` Greg KH

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=107828739888@kroah.com \
    --to=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox