diff mbox series

[v1] selftests/media_tests: fix a resource leak

Message ID 20231121093238.5376-1-zhujun2@cmss.chinamobile.com (mailing list archive)
State Rejected
Headers show
Series [v1] selftests/media_tests: fix a resource leak | expand

Commit Message

Zhu Jun Nov. 21, 2023, 9:32 a.m. UTC
From: zhujun2 <zhujun2@cmss.chinamobile.com>

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>
---

Hi Dan Carpenter 
	
	I believe that the Linux kernel code is sacred and should strictly adhere to C code conventions

thanks,
[Zhu Jun]

 tools/testing/selftests/media_tests/media_device_open.c | 2 ++
 tools/testing/selftests/media_tests/media_device_test.c | 2 ++
 2 files changed, 4 insertions(+)

Comments

Dan Carpenter Nov. 21, 2023, 9:42 a.m. UTC | #1
On Tue, Nov 21, 2023 at 01:32:38AM -0800, Zhu Jun wrote:
> From: zhujun2 <zhujun2@cmss.chinamobile.com>
> 
> 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>
> ---
> 
> Hi Dan Carpenter 
> 	
> 	I believe that the Linux kernel code is sacred and should strictly adhere to C code conventions
> 

*sigh*.  You do you, I guess.  This patch is pointless but I don't care
whether it's merged or not.

regards,
dan carpenter
diff mbox series

Patch

diff --git a/tools/testing/selftests/media_tests/media_device_open.c b/tools/testing/selftests/media_tests/media_device_open.c
index 93183a37b133..ae263eb78a2c 100644
--- a/tools/testing/selftests/media_tests/media_device_open.c
+++ b/tools/testing/selftests/media_tests/media_device_open.c
@@ -79,4 +79,6 @@  int main(int argc, char **argv)
 	else
 		printf("Media device model %s driver %s\n",
 			mdi.model, mdi.driver);
+
+	close(fd);
 }
diff --git a/tools/testing/selftests/media_tests/media_device_test.c b/tools/testing/selftests/media_tests/media_device_test.c
index 4b9953359e40..65888ce5c89f 100644
--- a/tools/testing/selftests/media_tests/media_device_test.c
+++ b/tools/testing/selftests/media_tests/media_device_test.c
@@ -100,4 +100,6 @@  int main(int argc, char **argv)
 		sleep(10);
 		count--;
 	}
+
+	close(fd);
 }