Messages in this thread | | | Date | Mon, 23 Apr 2012 13:40:48 -0700 | From | greg <> | Subject | Re: [PATCH 3/4][Trivial] lib/kobject.c : Check ktype in kobject_add_internal |
| |
On Sat, Apr 21, 2012 at 05:58:31PM +0800, yan wrote: > If someone calls kobject_init with null kobj_type, kobject_init can > detect it. But it does not have a return value, it just dumps stack. > In this case, a kobject_add after that will result in: > -->kobject_add_varg > -->kobject_add_internal > -->create_dir > -->sysfs_create_dir > -->sysfs_read_ns_type > -->kobj_child_ns_ops > In the end, it will call ->ktype->child_ns_type directly and we have > an oops. > > Check ktype before really add a kobject.
But how can we add a kobject without a valid ktype?
At the most, I'd prefer to warn about this, much like we warn about not having a name, and not just returning an error without a hint as to what went wrong.
greg k-h
| |