On 7/13/26 2:58 PM, Hongling Zeng wrote: > When kobject_init_and_add() fails in sysfs_slab_add(), the kobject > is not properly cleaned up, causing a memory leak. > > According to the kobject API documentation, when kobject_init_and_add() > returns an error, the caller must call kobject_put() to properly clean > up the memory associated with the object. The current code only frees > the 'name' string but forgets to release the kobject reference. This was intentional, please see commit 2420baa8e046 ("mm/slab: Allow cache creation to proceed even if sysfs registration fails"). > Fix this by calling kobject_put() before jumping to the error label. > > Fixes: 54b6a731025f ("slub: fix leak of 'name' in sysfs_slab_add") > Signed-off-by: Hongling Zeng > --- Uh, there was a similar attempt recently... https://lore.kernel.org/linux-mm/gimwkjjpvwu2sg5625b3eeatw2vhv7rs6enm3vepdduhcefbf5@xen5iec7sn3z Sounds like we need a comment saying it is intentional! -- Cheers, Harry / Hyeonggon