From: Dmitriy Monakhov <dmonakhov@sw.ru>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@suse.de>
Subject: [PATCH] driver core: handle sysfs_op failure while device_add
Date: Sun, 11 Mar 2007 22:11:51 +0300 [thread overview]
Message-ID: <874porvbm0.fsf@sw.ru> (raw)
depends on: "[PATCH] driver core: fix device_add error path"
- rearrange error path sequence, in order to make it more correct.
In fact if initial sequance was doA(); doB(); doC();
we should undo it with folowing sequance undoC(); undoB(); undoA();
- handle sysfs_ops failure
This patch kills "ignoring return value of 'sysfs_create_link'"
warning message.
Signed-off-by: Monakhov Dmitriy <dmonakhov@openvz.org>
---
drivers/base/core.c | 47 +++++++++++++++++++++++++++++++----------------
1 files changed, 31 insertions(+), 16 deletions(-)
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 245d703..bcfcfad 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -602,22 +602,34 @@ int device_add(struct device *dev)
}
if (dev->class) {
- sysfs_create_link(&dev->kobj, &dev->class->subsys.kset.kobj,
- "subsystem");
+ error = sysfs_create_link(&dev->kobj,
+ &dev->class->subsys.kset.kobj, "subsystem");
+ if (error)
+ goto ueventattrError;
/* 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) {
+ error = sysfs_create_link(
+ &dev->class->subsys.kset.kobj,
+ &dev->kobj, dev->bus_id);
+ if (error)
+ goto busLinkErr;
+ }
if (parent) {
- sysfs_create_link(&dev->kobj, &dev->parent->kobj,
- "device");
+ error = sysfs_create_link(&dev->kobj,
+ &dev->parent->kobj, "device");
+ if (error)
+ goto deviceLinkErr;
#ifdef CONFIG_SYSFS_DEPRECATED
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) {
+ error = sysfs_create_link(
+ &dev->parent->kobj,
+ &dev->kobj, class_name);
+ if (error)
+ goto classLinkErr;
+ }
#endif
}
}
@@ -673,12 +685,6 @@ int device_add(struct device *dev)
}
if (dev->class) {
- sysfs_remove_link(&dev->kobj, "subsystem");
- /* If this is not a "fake" compatible device, remove the
- * symlink from the class to the device. */
- if (dev->kobj.parent != &dev->class->subsys.kset.kobj)
- sysfs_remove_link(&dev->class->subsys.kset.kobj,
- dev->bus_id);
if (parent) {
#ifdef CONFIG_SYSFS_DEPRECATED
char *class_name = make_class_name(dev->class->name,
@@ -688,8 +694,17 @@ int device_add(struct device *dev)
class_name);
kfree(class_name);
#endif
+classLinkErr:
sysfs_remove_link(&dev->kobj, "device");
}
+deviceLinkErr:
+ /* If this is not a "fake" compatible device, remove the
+ * symlink from the class to the device. */
+ if (dev->kobj.parent != &dev->class->subsys.kset.kobj)
+ sysfs_remove_link(&dev->class->subsys.kset.kobj,
+ dev->bus_id);
+busLinkErr:
+ sysfs_remove_link(&dev->kobj, "subsystem");
}
ueventattrError:
device_remove_file(dev, &dev->uevent_attr);
--
1.5.0.1
reply other threads:[~2007-03-11 19:11 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=874porvbm0.fsf@sw.ru \
--to=dmonakhov@sw.ru \
--cc=gregkh@suse.de \
--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 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.