From nobody Mon Dec 15 22:07:52 2025 Received: from smtpout-04.galae.net (smtpout-04.galae.net [185.171.202.116]) (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 3627732E159; Fri, 31 Oct 2025 08:05:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.171.202.116 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761897903; cv=none; b=BLn4Z/lHNmH1iZ6X/eGgHoH59AuodVMV7HZHZbSvTYagODM+L8xJ/xA1niZpfORJYKLxU78kpISJRjJNUzNM08wVGyJFSVGn14HEeYZ0T12Y/bMVnWfc1KBjsCqm3vGZmQ19ihHlzxP0phv1UOW1dGApqs0PjVDGnrVTUKrk5Ac= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761897903; c=relaxed/simple; bh=QrlqFGzpjZmAoE0WhzSb3xJxJEZ4ob+vvZgBRHaTTSU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=MUpsKg4SOQgGwpZmc28v2XGx40Q8eCOiiKiwYvag10GN6m6kDU74trImHhwT+Ri7rIHL5DVRQyMmm5u2tLtByNZVzlSAXOJIEGC5cPYlbaX+gazyF0HWLD8wN+3Ue4MZsJ3oV8HI8wfuGQ9CXU8HRAJdOBZnVvGrtFBIFuAyuvI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=OKPcCVIo; arc=none smtp.client-ip=185.171.202.116 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="OKPcCVIo" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id E36B6C0E94C; Fri, 31 Oct 2025 08:04:38 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 689AF60704; Fri, 31 Oct 2025 08:04:59 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 17B0D1180FB56; Fri, 31 Oct 2025 09:04:56 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1761897898; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=eFjsOb3LsDj9nnNF55g5hT7ZyqAX/4ssZuJigX1uMXI=; b=OKPcCVIodpr2FvPQEQIKMLJSqfkfrhzSDK+GuLl6IJ4NE6vwikKkkeVE3GXMc3oh01NXhn FY9ogbksmMPbIovlojiC4seERIVZ7CHfZR4iSU+cvJgdmHJJbj7aR6py6oO7xV3HIG2MW3 Jsvmx3Ye1iuocTmmhpxbu3Ulq8B9IE/qukRmunVL1zexyKwiezMO10d5FCt1OiCITlM9Qp ElpVbUGzrGywmWfyVCIQ2uzgXaHVCzA/KNQjTKyqViVSqhog9iQkSog9Sw2zE3u2mPCye5 Beb4w6r277oI+feMb3N8X8L73lwks7EnckvigvwLTXwrxqkxcg9xybe/HOTMkA== From: "Bastien Curutchet (eBPF Foundation)" Date: Fri, 31 Oct 2025 09:04:40 +0100 Subject: [PATCH bpf-next v7 04/15] selftests/bpf: test_xsk: fix memory leak in testapp_stats_rx_dropped() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251031-xsk-v7-4-39fe486593a3@bootlin.com> References: <20251031-xsk-v7-0-39fe486593a3@bootlin.com> In-Reply-To: <20251031-xsk-v7-0-39fe486593a3@bootlin.com> To: =?utf-8?q?Bj=C3=B6rn_T=C3=B6pel?= , Magnus Karlsson , Maciej Fijalkowski , Jonathan Lemon , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Mykola Lysenko , Shuah Khan , "David S. Miller" , Jakub Kicinski , Jesper Dangaard Brouer Cc: Thomas Petazzoni , Alexis Lothore , netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, "Bastien Curutchet (eBPF Foundation)" X-Mailer: b4 0.14.2 X-Last-TLS-Session-Version: TLSv1.3 testapp_stats_rx_dropped() generates pkt_stream twice. The last generated is released by pkt_stream_restore_default() at the end of the test but we lose the pointer of the first pkt_stream. Release the 'middle' pkt_stream when it's getting replaced to prevent memory leaks. Reviewed-by: Maciej Fijalkowski Signed-off-by: Bastien Curutchet (eBPF Foundation) --- tools/testing/selftests/bpf/test_xsk.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tools/testing/selftests/bpf/test_xsk.c b/tools/testing/selftes= ts/bpf/test_xsk.c index 8d7c38eb32ca3537cb019f120c3350ebd9f8c6bc..eb18288ea1e4aa1c9337d16333b= 7174ecaed0999 100644 --- a/tools/testing/selftests/bpf/test_xsk.c +++ b/tools/testing/selftests/bpf/test_xsk.c @@ -536,6 +536,13 @@ static void pkt_stream_receive_half(struct test_spec *= test) struct pkt_stream *pkt_stream =3D test->ifobj_tx->xsk->pkt_stream; u32 i; =20 + if (test->ifobj_rx->xsk->pkt_stream !=3D test->rx_pkt_stream_default) + /* Packet stream has already been replaced so we have to release this on= e. + * The newly created one will be freed by the restore_default() at the + * end of the test + */ + pkt_stream_delete(test->ifobj_rx->xsk->pkt_stream); + test->ifobj_rx->xsk->pkt_stream =3D pkt_stream_generate(pkt_stream->nb_pk= ts, pkt_stream->pkts[0].len); pkt_stream =3D test->ifobj_rx->xsk->pkt_stream; --=20 2.51.0