Skip to contentSkip to conversation

stable-2.02 - cov: dmstats check for failing malloc

PATCH Marian Csontos 1 participant 1 message Mar 5, 2019

lore
Share & tools
lore
#0 lore raw
Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=c115d92287e86d153f2f09d7f8aea8065098f91c
Commit:        c115d92287e86d153f2f09d7f8aea8065098f91c
Parent:        ece117ee102684dc5380d30b73e4b992689eb85f
Author:        Marian Csontos <[email protected]>
AuthorDate:    Tue Mar 5 12:13:08 2019 +0100
Committer:     Marian Csontos <[email protected]>
CommitterDate: Tue Mar 5 12:13:08 2019 +0100

cov: dmstats check for failing malloc

Add missing check for allocation success.

Backported from: 9b7121226258f7dfe759cc1f8625cbfb80fec161

---
 tools/dmsetup.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
tools/dmsetup.c +4 -1
index 0b5b808..5b1a12e 100644
@@ -5216,7 +5216,10 @@ static int _do_stats_create_regions(struct dm_stats *dms,
 	if (!segments || (info.target_count == 1))
 		region_ids = &region_id;
 	else
-		region_ids = dm_malloc(info.target_count * sizeof(*region_ids));
+		if (!(region_ids = dm_malloc(info.target_count * sizeof(*region_ids)))) {
+			log_error("Failed to allocated region IDs.");
+			goto out;
+		}
 
 	do {
 		uint64_t segment_start, segment_len;