From patchwork Sat May 11 08:50:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 796285 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 6CEF8FBEA; Sat, 11 May 2024 08:50:37 +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=1715417437; cv=none; b=EI84xr5kLGax7R2jBfjOMvS4U/RTOi6/3VFvNzSGYppvw9uHggFrX0p5rKlBWYCdH2qFctgG7iq4u2j0LCJJ7+p9kCve7OdAeYa4TALA0WRpvU3s8w1jkkDcX1yJq44qJKl98zrtdNbn3Frg6Fwe50h2DtFlsiVUdw/yj7Wa0YE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715417437; c=relaxed/simple; bh=7OguetOiT+Z8CgMkKCjbz3+cqB8iRaQlGIKeWQiGTJE=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=NlUQbkczrzfkFg6cUsHAwAJzR6fGB77RRRXA5xGVmyElDaT71swvAAh2jUledwftbh7Lv7jgPxSmBa5WYNt8MZ+h6iynVvs+qiUpY970cSZPxzuIP/yDc9Lmusd+rNm9aewpwL39jplMEYOtm/l+5GnePDtDNxNzC9Zkzu+Jkv4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NBZ3V/JB; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NBZ3V/JB" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 046D4C2BBFC; Sat, 11 May 2024 08:50:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1715417437; bh=7OguetOiT+Z8CgMkKCjbz3+cqB8iRaQlGIKeWQiGTJE=; h=From:To:Cc:Subject:Date:From; b=NBZ3V/JBhkVF/6v+gg2H5HtRT5KDIhy29myDTWvsPmBQKiho5bq/n0EfIfaT1Syg7 t1GjIHkh8vUnWXToIbHlqckn5UGDkNPXzh8Zjdri08T9a4ttDpCx+qNOwCj6xrYsNy f007Lc/EIfKOlXvlLWdCDGY7PSgwtzrBheTEOljNyhpyOu3RV50P2cK+ZIWUlMpGlW Pe7ut/bfEI+u1QURhUirR2CNA5EuW3KQcS9YfCrZpS/M3q1OqDVgFNnAr1wVjEuFGd b1xQdq4HQLug52QiNaLG6Qtz6iJBklsDFtxR76wExR6IZ7xP+LTQv+edXL0UlOaqHZ MwlcsDCSdFwNw== From: Geliang Tang To: Andrii Nakryiko , Eduard Zingerman , Mykola Lysenko , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Shuah Khan Cc: Geliang Tang , bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, Geliang Tang Subject: [PATCH bpf-next] selftests/bpf: Free strdup memory in xdp_hw_metadata Date: Sat, 11 May 2024 16:50:24 +0800 Message-ID: X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Geliang Tang The strdup() function returns a pointer to a new string which is a duplicate of the string "ifname". Memory for the new string is obtained with malloc(), and need to be freed with free(). This patch adds this missing "free(saved_hwtstamp_ifname)" in cleanup() to avoid a potential memory leak in xdp_hw_metadata.c. Signed-off-by: Geliang Tang --- tools/testing/selftests/bpf/xdp_hw_metadata.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/testing/selftests/bpf/xdp_hw_metadata.c b/tools/testing/selftests/bpf/xdp_hw_metadata.c index 0859fe727da7..6f9956eed797 100644 --- a/tools/testing/selftests/bpf/xdp_hw_metadata.c +++ b/tools/testing/selftests/bpf/xdp_hw_metadata.c @@ -581,6 +581,8 @@ static void cleanup(void) if (bpf_obj) xdp_hw_metadata__destroy(bpf_obj); + + free((void *)saved_hwtstamp_ifname); } static void handle_signal(int sig)