Skip to contentSkip to conversation

master - coverity: add missing error check for str_list_add

PATCH Zdenek Kabelac 1 participant 1 message Mar 17, 2018

lore
Share & tools
lore
#0 lore raw
Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=fd6661dfcf7568d32a127e63b0d6c95c010688fb
Commit:        fd6661dfcf7568d32a127e63b0d6c95c010688fb
Parent:        d7273822757d6ccc7d4178f01c96fc3be52702a3
Author:        Zdenek Kabelac <[email protected]>
AuthorDate:    Sat Mar 17 14:15:11 2018 +0100
Committer:     Zdenek Kabelac <[email protected]>
CommitterDate: Sat Mar 17 23:33:58 2018 +0100

coverity: add missing error check for str_list_add

Validate success.

---
 tools/toollib.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
tools/toollib.c +5 -1
index eab6223..3f27a7a 100644
@@ -3088,7 +3088,11 @@ int process_each_lv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
 		if (lvargs_supplied && str_list_match_item(arg_lvnames, lvl->lv->name)) {
 			/* Remove LV from list of unprocessed LV names */
 			str_list_del(arg_lvnames, lvl->lv->name);
-			str_list_add(cmd->mem, &found_arg_lvnames, lvl->lv->name);
+			if (!str_list_add(cmd->mem, &found_arg_lvnames, lvl->lv->name)) {
+				log_error("strlist allocation failed.");
+				ret_max = ECMD_FAILED;
+				goto out;
+			}
 			process_lv = 1;
 		}