mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Stephen Hemminger <shemminger@osdl.org>
To: Tommi Virtanen <tv@tv.debian.net>, Greg KH <greg@kroah.com>
Cc: Leann Ogasawara <ogasawara@osdl.org>,
	netdev@oss.sgi.com, linux-kernel@vger.kernel.org
Subject: [PATCH] propogate errors from misc_register to caller
Date: Fri, 13 Feb 2004 11:21:00 -0800	[thread overview]
Message-ID: <20040213112100.4f42abc2@dell_ss3.pdx.osdl.net> (raw)
In-Reply-To: <20040213102755.27cf4fcd.shemminger@osdl.org>

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!

diff -Nru a/drivers/char/misc.c b/drivers/char/misc.c
--- a/drivers/char/misc.c	Fri Feb 13 11:15:29 2004
+++ b/drivers/char/misc.c	Fri Feb 13 11:15:29 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-02-13 19:21 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-02-13 18:27 [PATCH] don't allow / in class device names Stephen Hemminger
2004-02-13 19:21 ` Stephen Hemminger [this message]
2004-02-13 20:38   ` [PATCH] propogate errors from misc_register to caller Greg KH
2004-02-20  0:23   ` Greg KH
2004-02-13 20:34 ` [PATCH] don't allow / in class device names Greg KH
2004-02-13 20:45   ` Stephen Hemminger
2004-02-13 20:59     ` Greg KH
2004-02-16 22:43       ` maximilian attems

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=20040213112100.4f42abc2@dell_ss3.pdx.osdl.net \
    --to=shemminger@osdl.org \
    --cc=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@oss.sgi.com \
    --cc=ogasawara@osdl.org \
    --cc=tv@tv.debian.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®