From: Karel Zak Date: Thu, 25 Mar 2021 11:23:21 +0000 (+0100) Subject: lsmem: use ul_path_readf_string() readable for analysers [coverity scan] X-Git-Tag: v2.37-rc1~36 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4397707e7a42275d6a29e2a09bdec842dd8e3fb0;p=thirdparty%2Futil-linux.git lsmem: use ul_path_readf_string() readable for analysers [coverity scan] Signed-off-by: Karel Zak --- diff --git a/sys-utils/lsmem.c b/sys-utils/lsmem.c index 00f9d769c3..0b3d3ed12c 100644 --- a/sys-utils/lsmem.c +++ b/sys-utils/lsmem.c @@ -370,7 +370,7 @@ static void memory_block_read_attrs(struct lsmem *lsmem, char *name, if (ul_path_readf_s32(lsmem->sysmem, &x, "%s/removable", name) == 0) blk->removable = x == 1; - if (ul_path_readf_string(lsmem->sysmem, &line, "%s/state", name) > 0) { + if (ul_path_readf_string(lsmem->sysmem, &line, "%s/state", name) > 0 && line) { if (strcmp(line, "offline") == 0) blk->state = MEMORY_STATE_OFFLINE; else if (strcmp(line, "online") == 0) @@ -384,8 +384,9 @@ static void memory_block_read_attrs(struct lsmem *lsmem, char *name, blk->node = memory_block_get_node(lsmem, name); blk->nr_zones = 0; - if (lsmem->have_zones && - ul_path_readf_string(lsmem->sysmem, &line, "%s/valid_zones", name) > 0) { + if (lsmem->have_zones + && ul_path_readf_string(lsmem->sysmem, &line, "%s/valid_zones", name) > 0 + && line) { char *token = strtok(line, " "); @@ -394,7 +395,6 @@ static void memory_block_read_attrs(struct lsmem *lsmem, char *name, blk->nr_zones++; token = strtok(NULL, " "); } - free(line); } }