From nobody Sat Jul 25 21:59:35 2026 Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 09FDF2750FB for ; Mon, 13 Jul 2026 05:58:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=124.126.103.232 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783922325; cv=none; b=hFANBaWTE1yVlmigk/Dm92RiLwMcjNsDFHPCJZ48aBnZGYx+takpqw9MmR/5XaGVGv6nzYOe77AVP/fC66dd758eXKqOTvwCRm8m9dVmf95Fl2/o4PXnCmPoweNhIhvt3k+37NKGCuamm/3WFkbwlf0RTEz77NytucyDO7Vi/VE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783922325; c=relaxed/simple; bh=18h0WZAZBcE8ns9MfHJoNcFW6Ew0C0IIpDwBlyqV5tM=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=D/ogSiAICEDda4w9H5vk0VyBfIkHKxem5jGmSkTTFoRgnp+bteArbQzw6P6Yiws6T366wlJkjRPeGG/s4TAlU1PQc6kRvOBMgeFEN7oc/UZ56op7kRrE1tzwbYi6lHMOoqzKUdykpJMgMugELpVW9sZc1nXksoIhGN6JyLbn8/8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn; spf=pass smtp.mailfrom=kylinos.cn; arc=none smtp.client-ip=124.126.103.232 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kylinos.cn X-UUID: e19d9ac27e7f11f1aa26b74ffac11d73-20260713 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.3.12,REQID:1f8b2aec-638a-472a-8172-120feae4a683,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:e7bac3a,CLOUDID:09047162c704750643ea2dea6117a374,BulkI D:nil,BulkQuantity:0,Recheck:0,SF:102|136|850|865|898,TC:nil,Content:0|15| 50,EDM:-3,IP:nil,URL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0 ,OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 2,SSN|SDN X-CID-BAS: 2,SSN|SDN,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-CID-RHF: D41D8CD98F00B204E9800998ECF8427E X-UUID: e19d9ac27e7f11f1aa26b74ffac11d73-20260713 X-User: zenghongling@kylinos.cn Received: from localhost.localdomain [(10.44.16.150)] by mailgw.kylinos.cn (envelope-from ) (Generic MTA with TLSv1.3 TLS_AES_256_GCM_SHA384 256/256) with ESMTP id 1830885440; Mon, 13 Jul 2026 13:58:33 +0800 From: Hongling Zeng To: vbabka@kernel.org, harry@kernel.org, akpm@linux-foundation.org, hao.li@linux.dev, cl@gentwo.org, rientjes@google.com, roman.gushchin@linux.dev, vdavydov.dev@gmail.com, davej@fedoraproject.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, zhongling0719@126.com, Hongling Zeng Subject: [PATCH] mm/slub: fix kobject leak in sysfs_slab_add error path Date: Mon, 13 Jul 2026 13:58:29 +0800 Message-Id: <20260713055829.127864-1-zenghongling@kylinos.cn> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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. 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 --- mm/slub.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mm/slub.c b/mm/slub.c index 9ec774dc7009..fec2cd08d129 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -9690,8 +9690,10 @@ static int sysfs_slab_add(struct kmem_cache *s) =20 s->kobj.kset =3D kset; err =3D kobject_init_and_add(&s->kobj, &slab_ktype, NULL, "%s", name); - if (err) + if (err) { + kobject_put(&s->kobj); goto out; + } =20 if (!unmergeable) { /* Setup first alias */ --=20 2.25.1