From nobody Thu Apr 2 23:57:06 2026 Received: from mail115-100.sinamail.sina.com.cn (mail115-100.sinamail.sina.com.cn [218.30.115.100]) (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 AD0473921CA for ; Thu, 26 Mar 2026 03:18:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=218.30.115.100 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774495092; cv=none; b=qehYPrxM9P+Qv+zDAFswyhQ8QfYeykfmrV5+Pys5gwqVpjhlrgDdrXutKhtF8fN0kjBRJNmfYNwvjXbM51YUQc4YFLWnRifagbyzKZ6yU/YYYyr8HJk99cNaIf3VxsipOwRwQZtewRkbsJ5pZrp0mV7rjaH0EW4jnXvewi0i/EU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774495092; c=relaxed/simple; bh=5bQ84/Wihhmebd3SLk75uhUtAKAKqbgl8lGfkH6WarA=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=Vr3Vrk5zdaDDrGHToUmdcGZE0OfPQ/0kHDt244kRWshJwrI6nDPKtAP4fTh9F8c4VZTdI6HbKkbmm0nhOaUxO+mxbMeSPH6iQgmRa2+tdSv7h+tpTxJLf179IDntGHqwcD0OMOutbWYmgyuGVLYCGPm6MNUrzsLabxHG6Gy1PVI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sina.com; spf=pass smtp.mailfrom=sina.com; dkim=pass (1024-bit key) header.d=sina.com header.i=@sina.com header.b=eZiJF6Z9; arc=none smtp.client-ip=218.30.115.100 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sina.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sina.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=sina.com header.i=@sina.com header.b="eZiJF6Z9" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sina.com; s=201208; t=1774495088; bh=0hO+1H0a1Ekui1yDC8Wvpu+rnMGfVRgZsrKomK+irs0=; h=From:Subject:Date:Message-Id; b=eZiJF6Z9csDG05GdLpxMPmudImH5DVegbmgd5vVDBq/pO60xnywkDsVU6GunHAX3O JbKgmG4K0ZgVdl/yeqkqexRTG0nJRAayoikvvwzhqBg6SGvEi5T2sDL0haIzboB5E2 z87+wBzIme/f7Xtd2evEXhOsPrPTv3/BASwRcsFE= X-SMAIL-HELO: pek-lpg-core6.wrs.com Received: from unknown (HELO pek-lpg-core6.wrs.com)([60.247.85.88]) by sina.com (10.185.250.23) with ESMTP id 69C4A56A000046CB; Thu, 26 Mar 2026 11:18:04 +0800 (CST) X-Sender: johnny_haocn@sina.com X-Auth-ID: johnny_haocn@sina.com Authentication-Results: sina.com; spf=none smtp.mailfrom=johnny_haocn@sina.com; dkim=none header.i=none; dmarc=none action=none header.from=johnny_haocn@sina.com X-SMAIL-MID: 8625828912926 X-SMAIL-UIID: 1F4593A008014914B8E50DE26C6AF9EC-20260326-111804-1 From: Johnny Hao To: gregkh@linuxfoundation.org, stable@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Wang Yufen , Jiri Pirko , Jakub Kicinski , Johnny Hao Subject: [PATCH 5.15.y] netdevsim: Fix memory leak of nsim_dev->fa_cookie Date: Thu, 26 Mar 2026 11:18:02 +0800 Message-Id: <20260326031802.2410719-1-johnny_haocn@sina.com> X-Mailer: git-send-email 2.34.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" From: Wang Yufen [ Upstream commit 064bc7312bd09a48798418663090be0c776183db ] kmemleak reports this issue: unreferenced object 0xffff8881bac872d0 (size 8): comm "sh", pid 58603, jiffies 4481524462 (age 68.065s) hex dump (first 8 bytes): 04 00 00 00 de ad be ef ........ backtrace: [<00000000c80b8577>] __kmalloc+0x49/0x150 [<000000005292b8c6>] nsim_dev_trap_fa_cookie_write+0xc1/0x210 [netdevsi= m] [<0000000093d78e77>] full_proxy_write+0xf3/0x180 [<000000005a662c16>] vfs_write+0x1c5/0xaf0 [<000000007aabf84a>] ksys_write+0xed/0x1c0 [<000000005f1d2e47>] do_syscall_64+0x3b/0x90 [<000000006001c6ec>] entry_SYSCALL_64_after_hwframe+0x63/0xcd The issue occurs in the following scenarios: nsim_dev_trap_fa_cookie_write() kmalloc() fa_cookie nsim_dev->fa_cookie =3D fa_cookie .. nsim_drv_remove() The fa_cookie allocked in nsim_dev_trap_fa_cookie_write() is not freed. To fix, add kfree(nsim_dev->fa_cookie) to nsim_drv_remove(). Fixes: d3cbb907ae57 ("netdevsim: add ACL trap reporting cookie as a metadat= a") Signed-off-by: Wang Yufen Cc: Jiri Pirko Link: https://lore.kernel.org/r/1668504625-14698-1-git-send-email-wangyufen= @huawei.com Signed-off-by: Jakub Kicinski [ The context change is due to the commit 5e388f3dc38c ("netdevsim: move vfconfig to nsim_dev") in v5.16 which is irrelevant to the logic of this patch. ] Signed-off-by: Johnny Hao --- drivers/net/netdevsim/dev.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/netdevsim/dev.c b/drivers/net/netdevsim/dev.c index a7279356299a..d8f91bc38f40 100644 --- a/drivers/net/netdevsim/dev.c +++ b/drivers/net/netdevsim/dev.c @@ -1582,6 +1582,7 @@ void nsim_dev_remove(struct nsim_bus_dev *nsim_bus_de= v) ARRAY_SIZE(nsim_devlink_params)); devlink_unregister(devlink); devlink_resources_unregister(devlink, NULL); + kfree(nsim_dev->fa_cookie); devlink_free(devlink); } =20 --=20 2.34.1