From 1e02c1dc7986800b92ec2662b74ebbf0e1e82f4c Mon Sep 17 00:00:00 2001 From: root Date: Wed, 13 Mar 2019 14:41:41 +0800 Subject: [PATCH 12/17] cov: dmstats check for failing malloc Add missing check for allocation success. Backported from: 9b7121226258f7dfe759cc1f8625cbfb80fec161 --- tools/dmsetup.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/dmsetup.c b/tools/dmsetup.c index aca595d..d47484b 100644 --- a/tools/dmsetup.c +++ b/tools/dmsetup.c @@ -5228,7 +5228,10 @@ static int _do_stats_create_regions(struct dm_stats *dms, if (!segments || (info.target_count == 1)) region_ids = ®ion_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; -- 2.19.1