kobject_cleanup should set kobject.k_name to NULL?

From: sasin
Date: Sat May 24 2008 - 23:29:57 EST


Linux 2.6.24

platform_device_unregister -> device_unregister -> put_device ->
kobject_release -> kobject_cleanup frees kobject.k_name but does not set
it to NULL.

platform_device_register -> device_register -> device_add ->
kobject_set_name which calls kfree on this element. Calling kfree with
a NULL pointer is harmless, but in this case it is a NON-NULL freed
pointer, causing misbehaviour.

Currently I call device_(un)register combinations multiple times on a
statically allocated platform device structure to simulate hardware
device arrival/removal, and this results in crashes owing to the
behaviour above. Should this be considered a bug or am I using it
wrong?

Best regards,
Sasi
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/