summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHongling Zeng <zenghongling@kylinos.cn>2026-07-13 15:00:24 +0800
committerVlastimil Babka (SUSE) <vbabka@kernel.org>2026-07-13 15:53:18 +0200
commit56aa9b819edce4acfa879728af56534c951d1818 (patch)
treeddda577e38d5eda4ba8b3810bb751adc25332099
parentefa6a5b7bbb1bbdf304afc4a21da8ebacc2f758a (diff)
mm/slub: add comment explaining intentional kobject handling in sysfs_slab_add
Add a comment to clarify why we don't call kobject_put() when kobject_init_and_add() fails in sysfs_slab_add(). Per commit 2420baa8e046 ("mm/slab: Allow cache creation to proceed even if sysfs registration fails"), sysfs failures are treated as non-fatal and the cache continues to be used. Calling kobject_put() would trigger slab_kmem_cache_release() which frees the entire cache structure, so we intentionally skip it. Suggested-by: Harry Yoo <harry@kernel.org> Signed-off-by: Hongling Zeng <zenghongling@kylinos.cn> Acked-by: Harry Yoo (Oracle) <harry@kernel.org> Link: https://patch.msgid.link/20260713070024.153552-1-zenghongling@kylinos.cn Signed-off-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>
-rw-r--r--mm/slub.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/mm/slub.c b/mm/slub.c
index b650c1729437..da9efb040040 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -9676,6 +9676,11 @@ static int sysfs_slab_add(struct kmem_cache *s)
s->kobj.kset = kset;
err = kobject_init_and_add(&s->kobj, &slab_ktype, NULL, "%s", name);
+ /*
+ * Intentionally skip kobject_put(). See commit 2420baa8e046
+ * ("mm/slab: Allow cache creation to proceed even if sysfs
+ * registration fails")
+ */
if (err)
goto out;