]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
sandbox: terminate os_dirent_ls() result list
authorStephen Warren <swarren@nvidia.com>
Wed, 11 Jun 2014 16:26:23 +0000 (10:26 -0600)
committerSimon Glass <sjg@chromium.org>
Mon, 23 Jun 2014 21:37:24 +0000 (15:37 -0600)
Each node in the linked-list that os_dirent_ls() returns has its next
pointer set only when the next node is created. For the last node in the
list, there is no next node, so this never happens, and the next pointer
is never initialized. Explicitly initialize the next pointer so that it
isn't dangling. Without this, "sb ls" might crash.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Acked-by: Simon Glass <sjg@chromium.org>
arch/sandbox/cpu/os.c

index 57d04a45b22b7edf813629bbff4bb7c6e5bef255..1c4aa3f9bc4c4d054b7cbcd502163693a44319bc 100644 (file)
@@ -341,6 +341,7 @@ int os_dirent_ls(const char *dirname, struct os_dirent_node **headp)
                        ret = -ENOMEM;
                        goto done;
                }
+               next->next = NULL;
                strcpy(next->name, entry.d_name);
                switch (entry.d_type) {
                case DT_REG: