I think the actual kobj should be embedded in the struct, like `struct kobject kobj`.  Then call `kobject_init` on it instead of `kobject_create_and_add`, and free the struct via the kobject release callback.