[lkml]   [2012]   [Apr]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [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

 \ /
  Last update: 2012-04-23 22:43    [W:0.033 / U:0.564 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site