public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] Kobject: bail early if no new_parent in kobject_move()
@ 2009-10-01 14:50 Phil Carmody
  2009-10-01 14:49 ` Greg KH
  2009-10-05 16:37 ` Cornelia Huck
  0 siblings, 2 replies; 8+ messages in thread
From: Phil Carmody @ 2009-10-01 14:50 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel, Phil Carmody

From: Phil Carmody <ext-phil.2.carmody@nokia.com>

In the absense of kobj->kset, new_parent would remain NULL.
NULL-dereference shenanighans then ensues in the subsequent
sysfs_move_dir(..., new_parent) call. Bail early instead.

Signed-off-by: Phil Carmody <ext-phil.2.carmody@nokia.com>
---
 lib/kobject.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/lib/kobject.c b/lib/kobject.c
index b512b74..3574f94 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -471,8 +471,12 @@ int kobject_move(struct kobject *kobj, struct kobject *new_parent)
 		return -EINVAL;
 	new_parent = kobject_get(new_parent);
 	if (!new_parent) {
-		if (kobj->kset)
+		if (kobj->kset) {
 			new_parent = kobject_get(&kobj->kset->kobj);
+		} else {
+			error = -EINVAL;
+			goto out;
+		}
 	}
 	/* old object path */
 	devpath = kobject_get_path(kobj, GFP_KERNEL);
-- 
1.5.4.3


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2009-10-06 13:34 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-01 14:50 [PATCH 1/1] Kobject: bail early if no new_parent in kobject_move() Phil Carmody
2009-10-01 14:49 ` Greg KH
2009-10-01 15:01   ` Phil Carmody
2009-10-01 15:01     ` Greg KH
2009-10-05 16:37 ` Cornelia Huck
2009-10-06  8:52   ` Phil Carmody
2009-10-06 13:33     ` Cornelia Huck
2009-10-06 13:33     ` [PATCH] sysfs: Allow sysfs_move_dir(..., NULL) again Cornelia Huck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox