From f58fe33687c0ef8751dc407281440df5b20b80d8 Mon Sep 17 00:00:00 2001 From: Yonghua Huang Date: Tue, 22 May 2018 19:23:52 +0800 Subject: [PATCH] DM: avoid NULL pointer dereferenced in 'ioc_parse()' Pointer 'tmp' may be NULL before passing it to 'strtoul()' Signed-off-by: Yonghua Huang --- devicemodel/hw/platform/ioc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/devicemodel/hw/platform/ioc.c b/devicemodel/hw/platform/ioc.c index 53f8d1087..10071abe4 100644 --- a/devicemodel/hw/platform/ioc.c +++ b/devicemodel/hw/platform/ioc.c @@ -1043,7 +1043,8 @@ ioc_parse(const char *opts) snprintf(virtual_uart_path, sizeof(virtual_uart_path), "%s", param); if (tmp != NULL) { tmp = strtok(NULL, ","); - ioc_boot_reason = strtoul(tmp, 0, 0); + if (tmp != NULL) + ioc_boot_reason = strtoul(tmp, 0, 0); } free(param); return 0;