On Sat Jun 28, 2025 at 2:00 AM -03, Kurt Borja wrote: > Cleanup of allocated kobjects has many flaws. > > In tlmi_analyze(), allocated structs with an embedded kobject are freed > in error paths after the they were already initialized. > > In tlmi_release_attr(), which is called in tlmi_sysfs_init() error paths > and in module exit, kobject_del() is never called. This, between other > things, leaks the reference of the parent kobject, which is a kset in > this case. > > Fix this flaws simultaneously, first by avoiding the initialization of > kobjects in tlmi_analyze() and then by correctly cleaning them up in > tlmi_release_attr() using their kset's kobject list. > > Fixes: a40cd7ef22fb ("platform/x86: think-lmi: Add WMI interface support on Lenovo platforms") > Signed-off-by: Kurt Borja I missed some commits: Fixes: 30e78435d3bf ("platform/x86: think-lmi: Split kobject_init() and kobject_add() calls") Fixes: f7e506ec4a99 ("platform/x86: think-lmi: Fix possible mem-leaks on tlmi_analyze() error-exit") -- ~Kurt