[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <c4b4c2e3155280589fb539f952e58c77a1fa7e96.1254408493.git.ext-phil.2.carmody@nokia.com>
Date: Thu, 1 Oct 2009 17:50:48 +0300
From: Phil Carmody <ext-phil.2.carmody@...ia.com>
To: gregkh@...e.de
Cc: linux-kernel@...r.kernel.org,
Phil Carmody <ext-phil.2.carmody@...ia.com>
Subject: [PATCH 1/1] Kobject: bail early if no new_parent in kobject_move()
From: Phil Carmody <ext-phil.2.carmody@...ia.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@...ia.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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists