From: Stephen Warren <swar...@nvidia.com>

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 <swar...@nvidia.com>
---
 arch/sandbox/cpu/os.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c
index 57d04a45b22b..2cbd74c7b8fc 100644
--- a/arch/sandbox/cpu/os.c
+++ b/arch/sandbox/cpu/os.c
@@ -362,6 +362,7 @@ int os_dirent_ls(const char *dirname, struct os_dirent_node 
**headp)
                if (!head)
                        head = node;
        }
+       node->next = NULL;
        *headp = head;
 
 done:
-- 
1.8.1.5

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to