From nobody Mon Feb 9 12:23:54 2026 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (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 BB65C33B6D7; Wed, 29 Oct 2025 13:52:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.84.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761745970; cv=none; b=TYgnEXHjPWDmHhuAyh+SpjHNFSRcVnHe46u9YF9U/jq14waYXkNtv3nVTh3QnH7gQn1LdsUliGE4T4uFFFLe3u9KCqPrskGY3i1qFhmifXCSz6dDVZ/gGs9Qbjr/3x3T+udb7N5xaUHUokC7l9QSW/Y5kW4M4XaI3iCdqzV3x3c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761745970; c=relaxed/simple; bh=QrlqFGzpjZmAoE0WhzSb3xJxJEZ4ob+vvZgBRHaTTSU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=FcCtp37hvagtQE7349+E/i3BYgKnSjr2j8suHzjpe2Ifz88TT8M/QYMgfv2t82SLmg1p7S7xiTxf2plpHZ+CP3Z3XC1RmFMJH5RvYZaTsbdIj2x2D/7WeT8EsaqA/ej0i+NlqcnzR3AS2595AtoXUW5zuljNzFBdbqtBU6JEXiU= 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=jy/xZdBd; arc=none smtp.client-ip=185.246.84.56 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="jy/xZdBd" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 3F2661A174B; Wed, 29 Oct 2025 13:52:46 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 0DFE0606E8; Wed, 29 Oct 2025 13:52:46 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 990BE117F80F5; Wed, 29 Oct 2025 14:52:41 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1761745964; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=eFjsOb3LsDj9nnNF55g5hT7ZyqAX/4ssZuJigX1uMXI=; b=jy/xZdBdkYQ+SCeB5rIS5chE0TXQp8VlgE2BdFnbL6oyyy4qm5GWPT0Rh1vXib2lUfnsEf 63VBgneDNwnzVEUJ+hpU8utJbZLFPfAuQ11KPqc460d2QLlFaPOs1CH/bEXufZ5LH9uuBl gXkYXRRl8vFFQr9zwzuUCOPY/GUf6LjViz6c+2QRNi14MBA+uxpmkzxJpDma5CP2dVpJ2/ eJeqrzQ+Nn858gU/AIQYWjx4YrIzpJhXIHxNnuIiCyKBQnvyWkFDzAurUuy3zzkF3HHOmW ZNHd1kMS5ACigG2kutbMEZAvV6lAKjKzYFjK58y3AaCokQazOdpLkDUER+Dz9g== From: "Bastien Curutchet (eBPF Foundation)" Date: Wed, 29 Oct 2025 14:52:25 +0100 Subject: [PATCH bpf-next v6 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: <20251029-xsk-v6-4-5a63a64dff98@bootlin.com> References: <20251029-xsk-v6-0-5a63a64dff98@bootlin.com> In-Reply-To: <20251029-xsk-v6-0-5a63a64dff98@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