[U-Boot] [PATCH] sandbox: terminate os_dirent_ls() result list

Stephen Warren swarren at wwwdotorg.org
Wed Jun 11 18:21:04 CEST 2014


From: Stephen Warren <swarren at 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 <swarren at 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



More information about the U-Boot mailing list