From: Tom Rini Date: Tue, 18 Oct 2016 01:09:32 +0000 (-0400) Subject: sandboxfs: Fix resource leak X-Git-Tag: v2017.01-rc1~70^2~24 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=0317724e6c5db6229dbdc03dd9c9b68a559973fe;p=u-boot 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 Cc: Simon Glass Signed-off-by: Tom Rini Reviewed-by: Simon Glass --- diff --git a/fs/sandbox/sandboxfs.c b/fs/sandbox/sandboxfs.c index cd10fd6845..ca80261337 100644 --- a/fs/sandbox/sandboxfs.c +++ b/fs/sandbox/sandboxfs.c @@ -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)