From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796116327; b=Dc41X8ASwEl9vdssKXW/FFEx1qstrt51aAUYlleI2Q6TWHrmwegv/id5x79u1FsAv0lO 5yhVQFT0lz/gSLEBtbLQt7Ijge+5JantkiFgNGUf5x3brcJte0MvwQAcX8wy7QgW6YJOC j2kDCTLqLisu9VdSaI+bciEywlG76DHNlWQNW2C4J1MOvDaqnHb1LSnJWqq7floaDws24 IghHBqX92b/SUwq8OGx7PNvVxH19YDzTVTK96GLX1B+ePz17QajWtW7bgR0dcf291iNcs aVO+nhfwHCip79SyyRVcxai0aPzHh9WjjhIGPZOt1MiKBDRDYQ/QsFNpnXtZ5mhBcMw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796116327; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=yJ6fdrLNORuyurdtqXjc18VGP2zVLdQgtVFe2nQ3lAk=; b=Cx2g0f03G9crlm/vw0CxHcUwzJVpxrhp/WOACv6eWWZYUddWcd8K4MfkUeoLmabN080K PDN2FcXPuJMMbIRDSxF+1uyo+HHAvlQHqhnj2I6Am68OOs2k0TKeUVHXSTzy7iRZGyYUQ LSP57+Cfn9cIk8eIYK+VOJZ2rKMMx0Pjq1wwVKEi3ZAzcS/F1Ty4dMSRn+/BOoQagMcD6 w0WiwsswObKNNrB8g8w6yvcoM/VXo/tz/ek+7QSB5+ybwYdNe1/q85KByIFwJcpCw959+ eXjzZyp242nduXxVgovgWxEp0HeV9VqhIS3I1CqXmJczh4TUmUdxnpQmDUMPEWL8E9w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=O2ZA37Nc; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2DC2F606A31A for ; Tue, 1 Dec 2026 09:12:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=O2ZA37Nc Received: by smtp.kernel.org (Postfix) with ESMTPSA id AB7EB1F000C1; Tue, 1 Dec 2026 09:12:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796116326; bh=yJ6fdrLNORuyurdtqXjc18VGP2zVLdQgtVFe2nQ3lAk=; h=From:Subject:Reply-To:To:In-Reply-To:References:Date; b=O2ZA37NcycQ4IEqDPNqRlQEEBZQut4B0BfSX5E49LyZEXm7nlwQmQzUSD2pXLGWD5 atkXyg8QKhB7SD+ake/AeTYZJQKnehhUuKWLxBAsfAxG1I5nTJVrU81oVprSn1RZSe f4POtTJJspzdPJ2rh9tWRSIGHHW12bxiY/dOAYCNyuAJ5Y/4x6Q/JDD6CXuIU5qDob kXj/W6JjUFaNZGHx9q6Ed2WaJZ+vvPGPu3EpLiyPtcmrDdq5iQ9IjhJDv04H2ilD1V YRpy0Tb7ertYbsutaIDZuMbSWMBMMh+zDvF+jnWdl1tnnQCUIi/HXtMk9Geg/OvKJo dxWFfoHLQP28w== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH 3/3] KVM: selftests: Free the stats id string when no stats are defined Reply-To: sashiko-reviews@lists.linux.dev To: "Gokul K" , kvm@vger.kernel.org In-Reply-To: <20261201090632.2482795-4-gokul02k@gmail.com> References: <20261201090632.2482795-1-gokul02k@gmail.com> <20261201090632.2482795-4-gokul02k@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Tue, 01 Dec 2026 09:12:06 +0000 X-Mailing-List: kvm@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Low] KVM: selftests: stats_fd leak in stats_test() when header.num_desc =3D=3D 0 -- commit 38dd872f0f6bd2de7be54a91cb51a47a844eca82 Author: Gokul K KVM: selftests: Free the stats id string when no stats are defined This commit frees the allocated id string in stats_test() before returning early when header.num_desc is zero. > diff --git a/tools/testing/selftests/kvm/kvm_binary_stats_test.c b/tools/= testing/selftests/kvm/kvm_binary_stats_test.c > index b7dbde9c08436..89ae011ffae9f 100644 > --- a/tools/testing/selftests/kvm/kvm_binary_stats_test.c > +++ b/tools/testing/selftests/kvm/kvm_binary_stats_test.c > @@ -53,6 +53,7 @@ static void stats_test(int stats_fd) > /* Sanity check for other fields in header */ > if (header.num_desc =3D=3D 0) { > ksft_print_msg("No KVM stats defined!\n"); > + free(id); > return; > } [Severity: Low] Does this early return still leak stats_fd? main() passes newly opened or duplicated file descriptors directly to stats_test(), such as stats_test(kvm_dup(vm_stats_fds)) and stats_test(vm_get_stats_fd(vms[i])), and relies on the tail of stats_test() to close them: tools/testing/selftests/kvm/kvm_binary_stats_test.c:stats_test() { ... free(stats_data); free(stats_desc); free(id); close(stats_fd); TEST_ASSERT(fcntl(stats_fd, F_GETFD) =3D=3D -1, "Stats fd not freed"); } Placing a label right before free(id) at the end of stats_test() and jumping to it here would free id and close stats_fd without touching the uninitialized stats_data and stats_desc pointers. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261201090632.2482= 795-1-gokul02k@gmail.com?part=3D3