LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@suse.de>
Subject: [PATCH 1/28] Kobject: make kobject apis more robust in handling NULL pointers
Date: Wed, 7 Feb 2007 16:29:49 -0800 [thread overview]
Message-ID: <11708946163722-git-send-email-greg@kroah.com> (raw)
In-Reply-To: <20070208002908.GA4796@kroah.com>
From: Greg Kroah-Hartman <gregkh@suse.de>
It should be ok to pass in NULL for some kobject functions, so add error
checking for all exported kobject functions to be more robust.
Cc: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
lib/kobject.c | 19 +++++++++++++++++++
1 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/lib/kobject.c b/lib/kobject.c
index 7ce6dc1..9aed594 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -126,6 +126,8 @@ EXPORT_SYMBOL_GPL(kobject_get_path);
*/
void kobject_init(struct kobject * kobj)
{
+ if (!kobj)
+ return;
kref_init(&kobj->kref);
INIT_LIST_HEAD(&kobj->entry);
init_waitqueue_head(&kobj->poll);
@@ -366,6 +368,8 @@ out:
void kobject_del(struct kobject * kobj)
{
+ if (!kobj)
+ return;
sysfs_remove_dir(kobj);
unlink(kobj);
}
@@ -377,6 +381,8 @@ void kobject_del(struct kobject * kobj)
void kobject_unregister(struct kobject * kobj)
{
+ if (!kobj)
+ return;
pr_debug("kobject %s: unregistering\n",kobject_name(kobj));
kobject_uevent(kobj, KOBJ_REMOVE);
kobject_del(kobj);
@@ -523,6 +529,8 @@ int kset_add(struct kset * k)
int kset_register(struct kset * k)
{
+ if (!k)
+ return -EINVAL;
kset_init(k);
return kset_add(k);
}
@@ -535,6 +543,8 @@ int kset_register(struct kset * k)
void kset_unregister(struct kset * k)
{
+ if (!k)
+ return;
kobject_unregister(&k->kobj);
}
@@ -586,6 +596,9 @@ int subsystem_register(struct subsystem * s)
{
int error;
+ if (!s)
+ return -EINVAL;
+
subsystem_init(s);
pr_debug("subsystem %s: registering\n",s->kset.kobj.name);
@@ -598,6 +611,8 @@ int subsystem_register(struct subsystem * s)
void subsystem_unregister(struct subsystem * s)
{
+ if (!s)
+ return;
pr_debug("subsystem %s: unregistering\n",s->kset.kobj.name);
kset_unregister(&s->kset);
}
@@ -612,6 +627,10 @@ void subsystem_unregister(struct subsystem * s)
int subsys_create_file(struct subsystem * s, struct subsys_attribute * a)
{
int error = 0;
+
+ if (!s || !a)
+ return -EINVAL;
+
if (subsys_get(s)) {
error = sysfs_create_file(&s->kset.kobj,&a->attr);
subsys_put(s);
--
1.4.4.4
next prev parent reply other threads:[~2007-02-08 0:31 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-02-08 0:29 [GIT PATCH] Driver core patches for 2.6.20 Greg KH
2007-02-08 0:29 ` Greg KH [this message]
2007-02-08 0:29 ` [PATCH 2/28] Driver core: convert pcmcia code to use struct device Greg KH
2007-02-08 0:29 ` [PATCH 3/28] Driver core: convert SPI " Greg KH
2007-02-08 0:29 ` [PATCH 4/28] Network: convert network devices to use struct device instead of class_device Greg KH
2007-02-08 0:29 ` [PATCH 5/28] driver core: Remove device_is_registered() in device_move() Greg KH
2007-02-08 0:29 ` [PATCH 6/28] driver core: Allow device_move(dev, NULL) Greg KH
2007-02-08 0:29 ` [PATCH 7/28] MODULES: add the module name for built in kernel drivers Greg KH
2007-02-08 0:29 ` [PATCH 8/28] Modules: only add drivers/ direcory if needed Greg KH
2007-02-08 0:29 ` [PATCH 9/28] PCI: add the sysfs driver name to all modules Greg KH
2007-02-08 0:29 ` [PATCH 10/28] SERIO: " Greg KH
2007-02-08 0:29 ` [PATCH 11/28] USB: " Greg KH
2007-02-08 0:30 ` [PATCH 12/28] /sys/modules/*/holders Greg KH
2007-02-08 0:30 ` [PATCH 13/28] driver core fixes: make_class_name() retval checks Greg KH
2007-02-08 0:30 ` [PATCH 14/28] driver core fixes: device_register() retval check in platform.c Greg KH
2007-02-08 0:30 ` [PATCH 15/28] driver core: Don't stop probing on ->probe errors Greg KH
2007-02-08 0:30 ` [PATCH 16/28] driver core: Change function call order in device_bind_driver() Greg KH
2007-02-08 0:30 ` [PATCH 17/28] Driver core: fix race in sysfs between sysfs_remove_file() and read()/write() Greg KH
2007-02-08 0:30 ` [PATCH 18/28] sysfs: suppress lockdep warnings Greg KH
2007-02-08 0:30 ` [PATCH 19/28] sysfs: kobject_put cleanup Greg KH
2007-02-08 0:30 ` [PATCH 20/28] kobject: " Greg KH
2007-02-08 0:30 ` [PATCH 21/28] sysfs: error handling in sysfs, fill_read_buffer() Greg KH
2007-02-08 0:30 ` [PATCH 22/28] HOWTO: Add a reference to Harbison and Steele Greg KH
2007-02-08 0:30 ` [PATCH 23/28] SYSFS: Fix missing include of list.h in sysfs.h Greg KH
2007-02-08 0:30 ` [PATCH 24/28] Driver core: add uevent vars for devices of a class Greg KH
2007-02-08 0:30 ` [PATCH 25/28] Driver core: add device_type to struct device Greg KH
2007-02-08 0:30 ` [PATCH 26/28] Driver core: allow to delay the uevent at device creation time Greg KH
2007-02-08 0:30 ` [PATCH 27/28] Driver Core: Increase the default timeout value of the firmware subsystem Greg KH
2007-02-08 0:30 ` [PATCH 28/28] sysfs: Shadow directory support Greg KH
2007-02-08 17:20 ` [PATCH 10/28] SERIO: add the sysfs driver name to all modules Dmitry Torokhov
2007-02-08 18:51 ` 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=11708946163722-git-send-email-greg@kroah.com \
--to=greg@kroah.com \
--cc=gregkh@suse.de \
--cc=linux-kernel@vger.kernel.org \
--subject='Re: [PATCH 1/28] Kobject: make kobject apis more robust in handling NULL pointers' \
/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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).