From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 6FE7B1EB5E1; Wed, 25 Feb 2026 01:28:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771982915; cv=none; b=Gsc5lLQijg9VVCwS59E0GVPfUdTx0SJ55CfbV4KQQqybfFl4QBzsQKopmm8tk8Smp0QVYrsqxtqyaHNhaO76m43h7/5Kia/9K4q/W06xi5SBwQ3TbVRH258zhVsAfX7JE9mk8kmL+LKJKhTkeysV/LNEi7eyryq4iIYjcAePx68= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771982915; c=relaxed/simple; bh=qUFhKP3rqjeUvtsyavVGxnd4/NBVv/pA1Y7rH9TGY9I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cbFV5lu8lTWzgTOZxNKIFxB6LsdfupRtAhprJXqbUQVlKLBHCGS8fr2byuUL89cC4MAvHmIIGN1vyESl7HnspzaahLHcx5XSc1XdxOwEwLnd1IHJhssgB3DZ3AbtO007Azj+jbKZdsWXmaQCHRPqmq8Ry1mVEYxzxLu5spnrGvU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=TpWaYI3U; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="TpWaYI3U" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2DC1DC116D0; Wed, 25 Feb 2026 01:28:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1771982915; bh=qUFhKP3rqjeUvtsyavVGxnd4/NBVv/pA1Y7rH9TGY9I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TpWaYI3UyEWYtYQyYJrD6dbbZb2hEsMF+KYtRXQyIdnhiMLNQfVmH/+xj5mmQ/E2U S5ZdssJBySLzVQJMgBFBBytfp5NkXkpO7P4FkeXuuLNwcC6HCEuQ+j2s07h32M1Mb+ BYeQ8YbECRg/T53PCBGNXt6VUtON6AsDLFFpz/ds= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Kery Qi , Andrii Nakryiko , Yonghong Song , Sasha Levin Subject: [PATCH 6.19 095/781] selftests/bpf: Fix resource leak in serial_test_wq on attach failure Date: Tue, 24 Feb 2026 17:13:24 -0800 Message-ID: <20260225012402.021185663@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260225012359.695468795@linuxfoundation.org> References: <20260225012359.695468795@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Kery Qi [ Upstream commit a32ae2658471dd87a2f7a438388ed7d9a5767212 ] When wq__attach() fails, serial_test_wq() returns early without calling wq__destroy(), leaking the skeleton resources allocated by wq__open_and_load(). This causes ASAN leak reports in selftests runs. Fix this by jumping to a common clean_up label that calls wq__destroy() on all exit paths after successful open_and_load. Note that the early return after wq__open_and_load() failure is correct and doesn't need fixing, since that function returns NULL on failure (after internally cleaning up any partial allocations). Fixes: 8290dba51910 ("selftests/bpf: wq: add bpf_wq_start() checks") Signed-off-by: Kery Qi Signed-off-by: Andrii Nakryiko Acked-by: Yonghong Song Link: https://lore.kernel.org/bpf/20260121094114.1801-3-qikeyu2017@gmail.com Signed-off-by: Sasha Levin --- tools/testing/selftests/bpf/prog_tests/wq.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/wq.c b/tools/testing/selftests/bpf/prog_tests/wq.c index 15c67d23128b2..84831eecc935b 100644 --- a/tools/testing/selftests/bpf/prog_tests/wq.c +++ b/tools/testing/selftests/bpf/prog_tests/wq.c @@ -16,12 +16,12 @@ void serial_test_wq(void) /* re-run the success test to check if the timer was actually executed */ wq_skel = wq__open_and_load(); - if (!ASSERT_OK_PTR(wq_skel, "wq_skel_load")) + if (!ASSERT_OK_PTR(wq_skel, "wq__open_and_load")) return; err = wq__attach(wq_skel); if (!ASSERT_OK(err, "wq_attach")) - return; + goto clean_up; prog_fd = bpf_program__fd(wq_skel->progs.test_syscall_array_sleepable); err = bpf_prog_test_run_opts(prog_fd, &topts); @@ -31,6 +31,7 @@ void serial_test_wq(void) usleep(50); /* 10 usecs should be enough, but give it extra */ ASSERT_EQ(wq_skel->bss->ok_sleepable, (1 << 1), "ok_sleepable"); +clean_up: wq__destroy(wq_skel); } -- 2.51.0