Skip to content

Commit

Permalink
selftests/efivarfs: create-read: fix a resource leak
Browse files Browse the repository at this point in the history
[ Upstream commit 3f6f8a8 ]

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>
  • Loading branch information
zhujun2 authored and gregkh committed Nov 28, 2023
1 parent c685356 commit 0aaf807
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tools/testing/selftests/efivarfs/create-read.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit 0aaf807

Please sign in to comment.