Skip to contentSkip to conversation

sandboxfs: Fix resource leak

PATCH New Tom Rini 2 participants 3 messages Oct 18, 2016 – Oct 25, 2016

lore
Share & tools
lore

Tom Rini

author
#0 lore raw

PATCH 1/1 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 86167089b71c ("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]>
---
 fs/sandbox/sandboxfs.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
fs/sandbox/sandboxfs.c +3 -2
index cd10fd6845fb..ca8026133708 100644
@@ -88,15 +88,16 @@ int sandbox_fs_ls(const char *dirname)
 
 	ret = os_dirent_ls(dirname, &head);
 	if (ret)
-		return ret;
+		goto out;
 
 	for (node = head; node; node = node->next) {
 		printf("%s %10lu %s\n", os_dirent_get_typename(node->type),
 		       node->size, node->name);
 	}
+out:
 	os_dirent_free(head);
 
-	return 0;
+	return ret;
 }
 
 int sandbox_fs_exists(const char *filename)
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/1 sandboxfs: Fix resource leak

Quoted 4 lines · Tom Rini

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.

Quoted 8 lines
Fixes 86167089b71c ("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]>
---
 fs/sandbox/sandboxfs.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
#2 lore raw

PATCH 1/1 sandboxfs: Fix resource leak

Quoted 14 lines · Simon Glass
Quoted 4 lines · Tom Rini

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.

Quoted 8 lines
Fixes 86167089b71c ("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]>
---
 fs/sandbox/sandboxfs.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
Quoted 1 line

Applied to u-boot-dm/next, thanks