Skip to contentSkip to conversation

dm space map metadata: fix sm_bootstrap_get_nr_blocks()

PATCH In review Dan Carpenter 2 participants 2 messages Nov 29, 2014 – Dec 1, 2014

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dm space map metadata: fix sm_bootstrap_get_nr_blocks()

This function isn't right and it causes a static checker warning:

	drivers/md/dm-thin.c:3016 maybe_resize_data_dev()
	error: potentially using uninitialized 'sb_data_size'.

It should set "*count" and return zero on success the same as the sm_metadata_get_nr_blocks() function does earlier.

Fixes 3241b1d3e0aa ('dm: add persistent data library')

---
Static checker stuff. Not tested.

drivers/md/persistent-data/dm-space-map-metadata.c +3 -1
index 786b689..f4e22bc 100644
@@ -564,7 +564,9 @@ static int sm_bootstrap_get_nr_blocks(struct dm_space_map *sm, dm_block_t *count
 {
 	struct sm_metadata *smm = container_of(sm, struct sm_metadata, sm);
 
-	return smm->ll.nr_blocks;
+	*count = smm->ll.nr_blocks;
+
+	return 0;
 }
 
 static int sm_bootstrap_get_nr_free(struct dm_space_map *sm, dm_block_t *count)
#1 lore raw

Ack, thanks.

Quoted 28 lines · Dan Carpenter

This function isn't right and it causes a static checker warning:

	drivers/md/dm-thin.c:3016 maybe_resize_data_dev()
	error: potentially using uninitialized 'sb_data_size'.

It should set "*count" and return zero on success the same as the sm_metadata_get_nr_blocks() function does earlier.

Fixes 3241b1d3e0aa ('dm: add persistent data library')

---
Static checker stuff. Not tested.

drivers/md/persistent-data/dm-space-map-metadata.c +3 -1
index 786b689..f4e22bc 100644
@@ -564,7 +564,9 @@ static int sm_bootstrap_get_nr_blocks(struct dm_space_map *sm, dm_block_t *count
 {
 	struct sm_metadata *smm = container_of(sm, struct sm_metadata, sm);
 
-	return smm->ll.nr_blocks;
+	*count = smm->ll.nr_blocks;
+
+	return 0;
 }
 
 static int sm_bootstrap_get_nr_free(struct dm_space_map *sm, dm_block_t *count)