Skip to contentSkip to conversation

dm space maps: Fix uninitialized variable r2

PATCH Superseded Colin King 1 participant 2 messages May 21, 2021

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Colin King

author
#0 lore raw

PATCH 1/1 dm space maps: Fix uninitialized variable r2

From: Colin Ian King <[email protected]>

In the case where recursing(mm) is true variable r2 is not inintialized and an uninitialized value is being used in the call combine_errors later on. Fix this by setting r2 to zero.

Addresses-Coverity: ("Uninitialized scalar variable")

Fixes def6a7a9a7f0 ("dm space maps: improve performance with inc/dec on ranges of blocks")
---
 drivers/md/persistent-data/dm-space-map-metadata.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/md/persistent-data/dm-space-map-metadata.c +3 -2
index 3b70ee861cf5..5be5ef4c831f 100644
@@ -432,9 +432,10 @@ static int sm_metadata_dec_blocks(struct dm_space_map *sm, dm_block_t b, dm_bloc
 	int32_t nr_allocations;
 	struct sm_metadata *smm = container_of(sm, struct sm_metadata, sm);
 
-	if (recursing(smm))
+	if (recursing(smm)) {
 		r = add_bop(smm, BOP_DEC, b, e);
-	else {
+		r2 = 0;
+	} else {
 		in(smm);
 		r = sm_ll_dec(&smm->ll, b, e, &nr_allocations);
 		r2 = out(smm);
Signature · 1 line
2.31.1
#1 lore raw

NAK: [PATCH][next] dm space maps: Fix uninitialized variable r2

Quoted 21 lines · Colin King

From: Colin Ian King <[email protected]>

In the case where recursing(mm) is true variable r2 is not inintialized and an uninitialized value is being used in the call combine_errors later on. Fix this by setting r2 to zero.

Addresses-Coverity: ("Uninitialized scalar variable")

Fixes def6a7a9a7f0 ("dm space maps: improve performance with inc/dec on ranges of blocks")
---
 drivers/md/persistent-data/dm-space-map-metadata.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/md/persistent-data/dm-space-map-metadata.c +0 -0
index 3b70ee861cf5..5be5ef4c831f 100644
@@ -432,9 +432,10 @@ static int sm_metadata_dec_blocks(struct dm_space_map *sm, dm_block_t b, dm_bloc
 	int32_t nr_allocations;
 	struct sm_metadata *smm = container_of(sm, struct sm_metadata, sm);

drivers/md/persistent-data/dm-space-map-metadata.c static int sm_metadata_dec_blocks(struct dm_space_map *sm, dm_block_t b, dm_bloc · line 441

Quoted 10 lines
drivers/md/persistent-data/dm-space-map-metadata.c +3 -2
 
-	if (recursing(smm))
+	if (recursing(smm)) {
 		r = add_bop(smm, BOP_DEC, b, e);
-	else {
+		r2 = 0;
+	} else {
 		in(smm);
 		r = sm_ll_dec(&smm->ll, b, e, &nr_allocations);
 		r2 = out(smm);

There is a another occurrence of this, I'll send a V2 shortly