Skip to content

Commit 3f6f8a8

Browse files
zhujun2shuahkh
authored andcommitted
selftests/efivarfs: create-read: fix a resource leak
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>
1 parent 11df288 commit 3f6f8a8

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

tools/testing/selftests/efivarfs/create-read.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@ int main(int argc, char **argv)
3232
rc = read(fd, buf, sizeof(buf));
3333
if (rc != 0) {
3434
fprintf(stderr, "Reading a new var should return EOF\n");
35+
close(fd);
3536
return EXIT_FAILURE;
3637
}
3738

39+
close(fd);
3840
return EXIT_SUCCESS;
3941
}

0 commit comments

Comments
 (0)