]> git.sur5r.net Git - u-boot/blobdiff - fs/sandbox/sandboxfs.c
sandboxfs: Fix resource leak
[u-boot] / fs / sandbox / sandboxfs.c
index a920bc087712ff289c65eec948f0f234229f9f5c..ca8026133708d2e7083a004e92a952f19c6a66f9 100644 (file)
@@ -8,9 +8,13 @@
 #include <fs.h>
 #include <os.h>
 
-int sandbox_fs_set_blk_dev(block_dev_desc_t *rbdd, disk_partition_t *info)
+int sandbox_fs_set_blk_dev(struct blk_desc *rbdd, disk_partition_t *info)
 {
-       return 0;
+       /*
+        * Only accept a NULL struct blk_desc for the sandbox, which is when
+        * hostfs interface is used
+        */
+       return rbdd != NULL;
 }
 
 int sandbox_fs_read_at(const char *filename, loff_t pos, void *buffer,
@@ -84,14 +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)