From 02c5fe9debc0e31e97ee0f158627d5cb512c7940 Mon Sep 17 00:00:00 2001 From: David Gibson Date: Fri, 9 Mar 2018 13:38:15 +1100 Subject: [PATCH] tests: Remove valgrind error from tests/get_path In the case where fdt_get_path() returns an error, a debug print will attempt to display a poisoned buffer, running over the end and accessing uninitialized memory. Signed-off-by: David Gibson --- tests/get_path.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/get_path.c b/tests/get_path.c index 7352976..7701dba 100644 --- a/tests/get_path.c +++ b/tests/get_path.c @@ -42,7 +42,8 @@ static void check_path_buf(void *fdt, const char *path, int pathlen, int buflen) memset(buf, POISON, sizeof(buf)); /* poison the buffer */ len = fdt_get_path(fdt, offset, buf, buflen); - verbose_printf("get_path() %s -> %d -> %s\n", path, offset, buf); + verbose_printf("get_path() %s -> %d -> %s\n", path, offset, + len >= 0 ? buf : ""); if (buflen <= pathlen) { if (len != -FDT_ERR_NOSPACE)