From 9b7121226258f7dfe759cc1f8625cbfb80fec161 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Mon, 15 Oct 2018 14:58:24 +0200 Subject: [PATCH] cov: dmstats check for failing malloc Add missing check for allocation success. --- libdm/dm-tools/dmsetup.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libdm/dm-tools/dmsetup.c b/libdm/dm-tools/dmsetup.c index fb1a5747c..835fdcdc7 100644 --- a/libdm/dm-tools/dmsetup.c +++ b/libdm/dm-tools/dmsetup.c @@ -5224,7 +5224,10 @@ static int _do_stats_create_regions(struct dm_stats *dms, if (!segments || (info.target_count == 1)) region_ids = ®ion_id; else - region_ids = malloc(info.target_count * sizeof(*region_ids)); + if (!(region_ids = malloc(info.target_count * sizeof(*region_ids)))) { + log_error("Failed to allocated region IDs."); + goto out; + } do { uint64_t segment_start, segment_len;