lkml.org 
[lkml]   [2012]   [Apr]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[PATCH 4/4][Trivial] lib/kobject.c : check parameter in kobject_init_and_add
From
Date
If user turns to the simple interface kobject_init_and_add 
and gives a null kobject, kobject_init can detect it but
just dumps the stack. Then there is:
-->kobject_add_varg
-->kobject_set_name_vargs
In the end, it will reference kobj->name and we have an oops.

Check whether we have a valid kobject in kobject_init_and_add.

Signed-off-by: Yan Hong <clouds.yan@gmail.com>
---
lib/kobject.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/lib/kobject.c b/lib/kobject.c
index dd67855..bc05922 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -380,6 +380,9 @@ int kobject_init_and_add(struct kobject *kobj, struct kobj_type *ktype,
va_list args;
int retval;

+ if (!kobj)
+ return -EINVAL;
+
kobject_init(kobj, ktype);

va_start(args, fmt);
--
1.7.5.1




\
 
 \ /
  Last update: 2012-04-21 12:21    [W:0.028 / U:0.352 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site