From: Stephen Warren Date: Wed, 11 Jun 2014 16:26:23 +0000 (-0600) Subject: sandbox: terminate os_dirent_ls() result list X-Git-Tag: v2014.07-rc4~20^2~1 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=9c38c070085b566e2fc3f7696cdd4362c2759285;p=u-boot sandbox: terminate os_dirent_ls() result list 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 Acked-by: Simon Glass --- diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c index 57d04a45b2..1c4aa3f9bc 100644 --- a/arch/sandbox/cpu/os.c +++ b/arch/sandbox/cpu/os.c @@ -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: