From cbcca1950815b8df19716b3451db9e2e6da6e81a Mon Sep 17 00:00:00 2001 From: Dongkyun Son Date: Mon, 12 Jul 2021 13:12:08 +0900 Subject: [PATCH] Fix coverity defect: Dereference before null check CID 1238715 (#1 of 1): Dereference before null check (REVERSE_INULL) check_after_deref: Null-checking value suggests that it may be null, but it has already been dereferenced on all paths leading to the check. Change-Id: I9a8295a32fc709a9095126db6e2cf5f78cda6c9a Signed-off-by: Dongkyun Son --- src/sdb.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/sdb.c b/src/sdb.c index 4e1e67d..29ed3a8 100755 --- a/src/sdb.c +++ b/src/sdb.c @@ -1757,17 +1757,17 @@ static void init_capabilities(void) { "%s", UNKNOWN); E("fail to get the CPU architecture of model:%d\n", errno); } else { - // check for armv8 and 32 bit architecture, for it make the cpu arch as armv7l - if(!strncmp(value,"armv8",sizeof("armv8")+1) && !strncmp(arch,"32",sizeof("32")+1)) - { - D("Changing cpu arch in capability from %s to %s for %s bit\n",value,"armv7l",arch); - snprintf(g_capabilities.cpu_arch, sizeof(g_capabilities.cpu_arch), - "%s", "armv7l"); - } else { - snprintf(g_capabilities.cpu_arch, sizeof(g_capabilities.cpu_arch), - "%s", value); - } if (value != NULL) { + // check for armv8 and 32 bit architecture, for it make the cpu arch as armv7l + if(!strncmp(value,"armv8",sizeof("armv8")+1) && !strncmp(arch,"32",sizeof("32")+1)) + { + D("Changing cpu arch in capability from %s to %s for %s bit\n",value,"armv7l",arch); + snprintf(g_capabilities.cpu_arch, sizeof(g_capabilities.cpu_arch), + "%s", "armv7l"); + } else { + snprintf(g_capabilities.cpu_arch, sizeof(g_capabilities.cpu_arch), + "%s", value); + } free(value); } } -- 2.34.1