Skip to content

Commit 0317724

Browse files
trinisjg20
authored andcommitted
sandboxfs: Fix resource leak
Now that we free resources in sandbox_fs_ls Coverity is letting us know that in some cases we might leak. So in case of error we should still let os_dirent_free free anything that was allocated. Fixes: 8616708 ("sandbox/fs: Free memory allocated by os_dirent_ls") Reported-by: Coverity (CID: 153450) Cc: Stefan Brüns <[email protected]> Cc: Simon Glass <[email protected]> Signed-off-by: Tom Rini <[email protected]> Reviewed-by: Simon Glass <[email protected]>
1 parent a982b6f commit 0317724

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

fs/sandbox/sandboxfs.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,16 @@ int sandbox_fs_ls(const char *dirname)
8888

8989
ret = os_dirent_ls(dirname, &head);
9090
if (ret)
91-
return ret;
91+
goto out;
9292

9393
for (node = head; node; node = node->next) {
9494
printf("%s %10lu %s\n", os_dirent_get_typename(node->type),
9595
node->size, node->name);
9696
}
97+
out:
9798
os_dirent_free(head);
9899

99-
return 0;
100+
return ret;
100101
}
101102

102103
int sandbox_fs_exists(const char *filename)

0 commit comments

Comments
 (0)