New: Oops from create_dir (sysfs)
In the last couple of weeks, I've come across this crash a few times. In each case, my code was kobject_add()'ing a kobject to a kset that already contained a kobject of the same name.
Granted that these additions reflected faulty logic on the part of my code, but I was suprised that kobject_add didn't have a more intelligent response than crashing while creating the redundant sysfs dir.
Thoughts?
John
http://bugme.osdl.org/show_bug.cgi?id=2013
Signature · 1 line
John Rose <[email protected]>
Quoted 9 lines · John Rose
In the last couple of weeks, I've come across this crash a few times. In each case, my code was kobject_add()'ing a kobject to a kset that already contained a kobject of the same name.
Granted that these additions reflected faulty logic on the part of my code, but I was suprised that
kobject_adddidn't have a more intelligent response than crashing while creating the redundant sysfs dir.Thoughts?
The kobject code quickly pointed out the flaw in your code. Sounds like the proper response to me :)
thanks,
greg k-h
Quoted 1 line
The kobject code quickly pointed out the flaw in your code.
That it did, but an "already exists" return code from kobject_add would have pointed it out more quickly :)
John
Quoted 4 lines · John Rose
Quoted 1 line
The kobject code quickly pointed out the flaw in your code.
That it did, but an "already exists" return code from
kobject_addwould have pointed it out more quickly :)
Patches are always gladly accepted :)
thanks,
greg k-h
<crickets chirp>. That's one way to shut me up :)
In all seriousness, how much of a performance problem would be posed by throwing a kset_find_obj() check somewhere in the beginning of kobject_add()?
Thanks-
John
Quoted 11 lines · Greg KH
Quoted 4 lines · John Rose
Quoted 1 line
The kobject code quickly pointed out the flaw in your code.
That it did, but an "already exists" return code from
kobject_addwould have pointed it out more quickly :)Patches are always gladly accepted :)
thanks,
greg k-h
Quoted 1 line · John Rose
<crickets chirp>. That's one way to shut me up :)
Honestly, I like the way this currently works. You tried to do something not allowed, and the kernel dies. Now it would be nice to be able to provide a better type of error message to help the unsuspecting developer out, but that's just fluff :)
Quoted 3 lines
In all seriousness, how much of a performance problem would be posed by throwing a
kset_find_obj()check somewhere in the beginning ofkobject_add()?
Why not just fix the sysfs create_dir() function to not oops and report back the proper error message in this case?
thanks,
greg k-h