Skip to contentSkip to conversation

master - libdm: do not read region before checking dms for NULL (Coverity)

PATCH Bryn Reeves 1 participant 1 message Aug 17, 2015

lore
Share & tools
lore
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=8967776713e1be2d584bc8a9713eaaaf467d8ac7
Commit:        8967776713e1be2d584bc8a9713eaaaf467d8ac7
Parent:        d1c65d1b28c8942b4296da30dc95b7e7de33e5fe
Author:        Bryn M. Reeves <[email protected]>
AuthorDate:    Mon Aug 17 18:25:22 2015 +0100
Committer:     Bryn M. Reeves <[email protected]>
CommitterDate: Mon Aug 17 18:37:16 2015 +0100

libdm: do not read region before checking dms for NULL (Coverity)

dm_stats_get_area_start() attempts to assign a region pointer from a stats handle before checking it is non-NULL: move the assignment after the test.

---
 libdm/libdm-stats.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
libdm/libdm-stats.c +2 -1
index f8d0012..b7000cc 100644
@@ -1328,9 +1328,10 @@ int dm_stats_get_current_region_area_len(const struct dm_stats *dms,
 int dm_stats_get_area_start(const struct dm_stats *dms, uint64_t *start,
 			    uint64_t region_id, uint64_t area_id)
 {
-	struct dm_stats_region *region = &dms->regions[region_id];
+	struct dm_stats_region *region;
 	if (!dms || !dms->regions)
 		return_0;
+	region = &dms->regions[region_id];
 	*start = region->start + region->step * area_id;
 	return 1;
 }