From: "Akinobu Mita" <akinobu.mita@gmail.com>
To: "Linux Kernel List" <linux-kernel@vger.kernel.org>,
"Greg KH" <greg@kroah.com>,
"Russell King" <rmk+lkml@arm.linux.org.uk>
Subject: [PATCH 3/3] driver core: check sysfs_create_link() errors
Date: Tue, 27 Feb 2007 23:04:59 +0900 [thread overview]
Message-ID: <961aa3350702270604q53df742dvda40c47efdfd1044@mail.gmail.com> (raw)
This patch kills __must_check warnings for missing sysfs_create_link().
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@suse.de>
---
drivers/base/core.c | 59 +++++++++++++++++++++++++++++++++++++++-------------
1 file changed, 45 insertions(+), 14 deletions(-)
Index: 2.6-mm/drivers/base/core.c
===================================================================
--- 2.6-mm.orig/drivers/base/core.c
+++ 2.6-mm/drivers/base/core.c
@@ -487,31 +487,61 @@ static int setup_parent(struct device *d
return 0;
}
-static void device_add_links(struct device *dev, struct device *parent)
+static int device_add_links(struct device *dev, struct device *parent)
{
+ int err;
+
if (dev->class) {
- sysfs_create_link(&dev->kobj, &dev->class->subsys.kset.kobj,
- "subsystem");
+ err = sysfs_create_link(&dev->kobj,
+ &dev->class->subsys.kset.kobj,
+ "subsystem");
+ if (err)
+ return err;
+
/* If this is not a "fake" compatible device, then create the
* symlink from the class to the device. */
- if (dev->kobj.parent != &dev->class->subsys.kset.kobj)
- sysfs_create_link(&dev->class->subsys.kset.kobj,
- &dev->kobj, dev->bus_id);
+ if (dev->kobj.parent != &dev->class->subsys.kset.kobj) {
+ err = sysfs_create_link(&dev->class->subsys.kset.kobj,
+ &dev->kobj, dev->bus_id);
+ if (err)
+ goto out1;
+ }
#ifdef CONFIG_SYSFS_DEPRECATED
if (parent) {
char *class_name = NULL;
- sysfs_create_link(&dev->kobj, &dev->parent->kobj,
- "device");
+ err = sysfs_create_link(&dev->kobj, &dev->parent->kobj,
+ "device");
+ if (err)
+ goto out2;
class_name = make_class_name(dev->class->name,
&dev->kobj);
- if (class_name)
- sysfs_create_link(&dev->parent->kobj,
- &dev->kobj, class_name);
+ if (class_name) {
+ err = sysfs_create_link(&dev->parent->kobj,
+ &dev->kobj, class_name);
+ if (err) {
+ kfree(class_name);
+ goto out3;
+ }
+
+ }
kfree(class_name);
}
#endif
}
+
+ return 0;
+
+#ifdef CONFIG_SYSFS_DEPRECATED
+out3:
+ sysfs_remove_link(&dev->kobj, "device");
+out2:
+#endif
+ sysfs_remove_link(&dev->class->subsys.kset.kobj, dev->bus_id);
+out1:
+ sysfs_remove_link(&dev->kobj, "subsystem");
+
+ return err;
}
static void device_remove_links(struct device *dev, struct device *parent)
@@ -611,8 +641,9 @@ int device_add(struct device *dev)
dev->devt_attr = attr;
}
- device_add_links(dev, parent);
-
+ error = device_add_links(dev, parent);
+ if (error)
+ goto LinksError;
if ((error = device_add_attrs(dev)))
goto AttrsError;
if ((error = device_add_groups(dev)))
@@ -652,7 +683,7 @@ int device_add(struct device *dev)
device_remove_attrs(dev);
AttrsError:
device_remove_links(dev, parent);
-
+ LinksError:
if (dev->devt_attr) {
device_remove_file(dev, dev->devt_attr);
kfree(dev->devt_attr);
reply other threads:[~2007-02-27 14:05 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=961aa3350702270604q53df742dvda40c47efdfd1044@mail.gmail.com \
--to=akinobu.mita@gmail.com \
--cc=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rmk+lkml@arm.linux.org.uk \
/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®