]> git.baikalelectronics.ru Git - kernel.git/commit
platform/x86: think-lmi: Split kobject_init() and kobject_add() calls
authorHans de Goede <hdegoede@redhat.com>
Sat, 17 Jul 2021 14:36:06 +0000 (16:36 +0200)
committerHans de Goede <hdegoede@redhat.com>
Sat, 17 Jul 2021 14:39:55 +0000 (16:39 +0200)
commit6515393faf2d60b2dd78a02607e4d12f303422d2
tree8133dae389a0134d542e7af07ec0b3204ac206a7
parenta432863c92eaeba7d7a0a973f9fe9ebb8132ce0a
platform/x86: think-lmi: Split kobject_init() and kobject_add() calls

tlmi_sysfs_init() calls tlmi_release_attr() on errors which calls
kobject_put() for attributes created by tlmi_analyze(), but if we
bail early because of an error, then this means that some of the
kobjects will not have been initialized yet; and we should thus not
call kobject_put() on them.

Switch from using kobject_init_and_add() inside tlmi_sysfs_init() to
initializing all the created kobjects directly in tlmi_analyze() and
only adding them from tlmi_sysfs_init(). This way all kobjects will
always be initialized when tlmi_release_attr() gets called.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20210717143607.3580-2-hdegoede@redhat.com
drivers/platform/x86/think-lmi.c