Skip to content

Commit b7ce90b

Browse files
committed
sprandom: wait to free validity_dist
This array is actually used to calculate invalid_capacity. So wait to free it until the very end. Fixes: 8c8e705 ("sprandom: drop validity_dist after use") Signed-off-by: Vincent Fu <vincent.fu@samsung.com>
1 parent d4b1dce commit b7ce90b

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

sprandom.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -602,8 +602,6 @@ static int sprandom_setup(struct sprandom_info *spr_info, uint64_t logical_size,
602602
double inv = (1.0 - validity_dist[i]) * (double)PCT_PRECISION;
603603
spr_info->invalid_pct[i] = (int)round(inv);
604604
}
605-
free(validity_dist);
606-
validity_dist = NULL;
607605

608606
region_sz = physical_size / spr_info->num_regions;
609607
region_write_count = region_sz / align_bs;
@@ -641,6 +639,7 @@ static int sprandom_setup(struct sprandom_info *spr_info, uint64_t logical_size,
641639
total_alloc,
642640
bytes2str_simple(bytes2str_buf, sizeof(bytes2str_buf), total_alloc));
643641

642+
free(validity_dist);
644643
return 0;
645644
err:
646645
free(validity_dist);

0 commit comments

Comments
 (0)