]> git.sur5r.net Git - u-boot/commitdiff
sandboxfs: Fix resource leak
authorTom Rini <trini@konsulko.com>
Tue, 18 Oct 2016 01:09:32 +0000 (21:09 -0400)
committerSimon Glass <sjg@chromium.org>
Fri, 2 Dec 2016 17:37:47 +0000 (10:37 -0700)
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 <stefan.bruens@rwth-aachen.de>
Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
fs/sandbox/sandboxfs.c

index cd10fd6845fbe46ee6802fff801342e6cdf814cf..ca8026133708d2e7083a004e92a952f19c6a66f9 100644 (file)
@@ -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)