]> Git Repo - J-linux.git/commitdiff
selftests/efivarfs: create-read: fix a resource leak
authorzhujun2 <[email protected]>
Wed, 18 Oct 2023 01:59:21 +0000 (18:59 -0700)
committerShuah Khan <[email protected]>
Wed, 18 Oct 2023 20:33:44 +0000 (14:33 -0600)
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 <[email protected]>
Signed-off-by: Shuah Khan <[email protected]>
tools/testing/selftests/efivarfs/create-read.c

index 9674a19396a325e06336a55942861ab43d086f7e..7bc7af4eb2c17f5e301a01e6ec130e40e6b49173 100644 (file)
@@ -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;
 }
This page took 0.048788 seconds and 4 git commands to generate.