Skip to contentSkip to conversation

New: Oops from create_dir (sysfs)

Bug 2013 John Rose 2 participants 6 messages Feb 4, 2004

lore
Share & tools
lore

John Rose

author
#0 lore raw

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]>
#1 lore raw
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_add didn'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

author
#2 lore raw
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

#3 lore raw
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_add would have pointed it out more quickly :)

Patches are always gladly accepted :)

thanks,

greg k-h

author
#4 lore raw

<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_add would have pointed it out more quickly :)

Patches are always gladly accepted :)

thanks,

greg k-h

#5 lore raw
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 of kobject_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