From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 75EF135F61A for ; Mon, 13 Jul 2026 06:08:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783922882; cv=none; b=SAFkCLaYqUr+eBuK2hyPmmI3LvWj6vRvViukjrusnYXvfh4zA4K2m1yvGhTFlBsXXfS6X+Z3MuP96UeDSJxaM+4WwEiFxKqUezD9ISUYFLYtOQhxXShuB1J4NoPPPxRJq7SRv8cJfv+HnT2/IpiwbF9GCTcb466nyyVVRT3sM2I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783922882; c=relaxed/simple; bh=H1des+LVbw6lhuT1ysuivk1WMn5ZEGWn284WG3CxnpU=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Bn3DQydq98Fx8BREqpsG3xUcFee29+1q3FNXf9n+7hD2fq6CjNKuEGQpZ+dTnGDUe9feiCaPMda++41jmO76GQhU6OSa7Ei2Mu/kW5oiWxTpLvRjPkWp5+nkYRNCMPldROof7Za1vgwgaoQ4b1uEpzidJVF6EKSrkZ5qk7rf7gY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=WLF9tnBC; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="WLF9tnBC" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1837B1F000E9; Mon, 13 Jul 2026 06:07:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1783922881; bh=H1des+LVbw6lhuT1ysuivk1WMn5ZEGWn284WG3CxnpU=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=WLF9tnBCCCfwUF7aH1Q2bSfpGAqsSh+zRoPizUboAXBmnb7QUnXgEit58Vgbbu+HT 30y4lkAE1wz6YsOqSmc89o3OcKScHH5/z+VTFxlwLxzgNUxs0kNaOJcQRYaY4jqmnA e732PpDnvKf6zV93ZT4nocT9srZQXcNpvS0vUX9FDxDp+X0RT9GFxJbI1UeN4Wpe8/ 8wGllpXvHSpt8/W+bC7KJLrjm94LZTp1zriPusCxWI8E+bFa3bHQJgw5b5FqugldfQ BM6CD43o9tce1SdpIDS2bvi10Yagufv65Y2YJvrVCn9sYtGw/GQg8cj3tSYQp6m82l AVmwDUFni1RJw== Message-ID: Date: Mon, 13 Jul 2026 15:07:54 +0900 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] mm/slub: fix kobject leak in sysfs_slab_add error path To: Hongling Zeng , vbabka@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 References: <20260713055829.127864-1-zenghongling@kylinos.cn> Content-Language: en-US From: Harry Yoo In-Reply-To: <20260713055829.127864-1-zenghongling@kylinos.cn> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------QkD6sNHryRPp7GhYmc0ogbyC" This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --------------QkD6sNHryRPp7GhYmc0ogbyC Content-Type: multipart/mixed; boundary="------------hgucM73EFMWBf00Sp10C1CQm"; protected-headers="v1" From: Harry Yoo To: Hongling Zeng , vbabka@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 Message-ID: Subject: Re: [PATCH] mm/slub: fix kobject leak in sysfs_slab_add error path References: <20260713055829.127864-1-zenghongling@kylinos.cn> In-Reply-To: <20260713055829.127864-1-zenghongling@kylinos.cn> --------------hgucM73EFMWBf00Sp10C1CQm Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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. >=20 > 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. >=20 > 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/gimwkjjpvwu2sg5625b3eeatw2vhv7rs6enm3vep= dduhcefbf5@xen5iec7sn3z Sounds like we need a comment saying it is intentional! --=20 Cheers, Harry / Hyeonggon --------------hgucM73EFMWBf00Sp10C1CQm-- --------------QkD6sNHryRPp7GhYmc0ogbyC Content-Type: application/pgp-signature; name="OpenPGP_signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="OpenPGP_signature.asc" -----BEGIN PGP SIGNATURE----- iHUEARYKAB0WIQQQ1ub6gR5ogjaKRmOGXBN6rc5S1gUCalSAuwAKCRCGXBN6rc5S 1vsbAQDs4Lw4Ek8Gn4jlJt8wBRwcRV7RGW3vinWpQ3r41+qVOgEAl98i7EfRDvbp Jr6Y3PPHuaApvEw85RpyULz+SElaPwo= =0KHw -----END PGP SIGNATURE----- --------------QkD6sNHryRPp7GhYmc0ogbyC--