All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: zhujun2 <zhujun2@cmss.chinamobile.com>,
	Shuah Khan <skhan@linuxfoundation.org>,
	Sasha Levin <sashal@kernel.org>,
	shuah@kernel.org, linux-kselftest@vger.kernel.org
Subject: [PATCH AUTOSEL 5.10 11/11] selftests/efivarfs: create-read: fix a resource leak
Date: Tue,  7 Nov 2023 07:30:44 -0500	[thread overview]
Message-ID: <20231107123100.3762796-11-sashal@kernel.org> (raw)
In-Reply-To: <20231107123100.3762796-1-sashal@kernel.org>

From: zhujun2 <zhujun2@cmss.chinamobile.com>

[ Upstream commit 3f6f8a8c5e11a9b384a36df4f40f0c9a653b6975 ]

The opened file should be closed in main(), otherwise resource
leak will occur that this problem was discovered by code reading

Signed-off-by: zhujun2 <zhujun2@cmss.chinamobile.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 tools/testing/selftests/efivarfs/create-read.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/testing/selftests/efivarfs/create-read.c b/tools/testing/selftests/efivarfs/create-read.c
index 9674a19396a32..7bc7af4eb2c17 100644
--- a/tools/testing/selftests/efivarfs/create-read.c
+++ b/tools/testing/selftests/efivarfs/create-read.c
@@ -32,8 +32,10 @@ int main(int argc, char **argv)
 	rc = read(fd, buf, sizeof(buf));
 	if (rc != 0) {
 		fprintf(stderr, "Reading a new var should return EOF\n");
+		close(fd);
 		return EXIT_FAILURE;
 	}
 
+	close(fd);
 	return EXIT_SUCCESS;
 }
-- 
2.42.0


      parent reply	other threads:[~2023-11-07 12:44 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-07 12:30 [PATCH AUTOSEL 5.10 01/11] drm/komeda: drop all currently held locks if deadlock happens Sasha Levin
2023-11-07 12:30 ` Sasha Levin
2023-11-07 12:30 ` [PATCH AUTOSEL 5.10 02/11] drm/msm/dp: skip validity check for DP CTS EDID checksum Sasha Levin
2023-11-07 12:30   ` Sasha Levin
2023-11-07 12:30 ` [PATCH AUTOSEL 5.10 03/11] drm/amd: Fix UBSAN array-index-out-of-bounds for SMU7 Sasha Levin
2023-11-07 12:30   ` Sasha Levin
2023-11-07 12:30   ` Sasha Levin
2023-11-07 12:30 ` [PATCH AUTOSEL 5.10 04/11] drm/radeon: Fix UBSAN array-index-out-of-bounds for Radeon HD 5430 Sasha Levin
2023-11-07 12:30   ` Sasha Levin
2023-11-07 12:30   ` Sasha Levin
2023-11-07 12:30 ` [PATCH AUTOSEL 5.10 05/11] drm/amd: Fix UBSAN array-index-out-of-bounds for Polaris and Tonga Sasha Levin
2023-11-07 12:30   ` Sasha Levin
2023-11-07 12:30   ` Sasha Levin
2023-11-07 12:30 ` [PATCH AUTOSEL 5.10 06/11] drm/amdgpu: Fix potential null pointer derefernce Sasha Levin
2023-11-07 12:30   ` Sasha Levin
2023-11-07 12:30   ` Sasha Levin
2023-11-07 12:30 ` [PATCH AUTOSEL 5.10 07/11] drm/panel: fix a possible null pointer dereference Sasha Levin
2023-11-07 12:30   ` Sasha Levin
2023-11-07 12:30 ` [PATCH AUTOSEL 5.10 08/11] drm/panel/panel-tpo-tpg110: " Sasha Levin
2023-11-07 12:30   ` Sasha Levin
2023-11-07 12:30 ` [PATCH AUTOSEL 5.10 09/11] drm/panel: st7703: Pick different reset sequence Sasha Levin
2023-11-07 12:30   ` Sasha Levin
2023-11-07 12:30 ` [PATCH AUTOSEL 5.10 10/11] drm/amdgpu: Fix a null pointer access when the smc_rreg pointer is NULL Sasha Levin
2023-11-07 12:30   ` Sasha Levin
2023-11-07 12:30   ` Sasha Levin
2023-11-07 12:30 ` Sasha Levin [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231107123100.3762796-11-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=shuah@kernel.org \
    --cc=skhan@linuxfoundation.org \
    --cc=stable@vger.kernel.org \
    --cc=zhujun2@cmss.chinamobile.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.