Skip to contentSkip to conversation

lib/kobject.c : Check parameter in kobject_set_name

PATCH In review yan 2 participants 2 messages Apr 21, 2012 – Apr 23, 2012

Subsystems (2)
lore
Share & tools
lore

yan

author
#0 lore raw

PATCH 2/4 lib/kobject.c : Check parameter in kobject_set_name

kobject_set_name is exported and is just a wrapper for kobject_set_name_vargs which does not check its parameter kobj.
So check this parameter in kobject_set_name.

---
 lib/kobject.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
lib/kobject.c +3 -0
index 56c8cb3..dd67855 100644
@@ -248,6 +248,9 @@ int kobject_set_name(struct kobject *kobj, const char *fmt, ...)
 	va_list vargs;
 	int retval;
 
+	if (!kobj)
+		return -EINVAL;
+
 	va_start(vargs, fmt);
 	retval = kobject_set_name_vargs(kobj, fmt, vargs);
 	va_end(vargs);
Signature · 1 line
1.7.5.1
maintainer
#1 lore raw
Quoted 3 lines · yan

kobject_set_name is exported and is just a wrapper for kobject_set_name_vargs which does not check its parameter kobj.
So check this parameter in kobject_set_name.

I have the same objection to this patch, why is it needed? All in-kernel users do this properly, so the patch isn't needed.

Remember, kernel programming isn't always about being defensive.

greg k-h