Skip to content

Commit 6b5da52

Browse files
qianfengrongmartinkpetersen
authored andcommitted
scsi: scsi_debug: Use vcalloc() to simplify code
Use vcalloc() instead of vmalloc() followed by bitmap_zero() to simplify the function sdebug_add_store(). Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com> Link: https://lore.kernel.org/r/20250806124633.383426-3-rongqianfeng@vivo.com Reviewed-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent daedd69 commit 6b5da52

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

drivers/scsi/scsi_debug.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8782,8 +8782,8 @@ static int sdebug_add_store(void)
87828782
/* Logical Block Provisioning */
87838783
if (scsi_debug_lbp()) {
87848784
map_size = lba_to_map_index(sdebug_store_sectors - 1) + 1;
8785-
sip->map_storep = vmalloc(array_size(sizeof(long),
8786-
BITS_TO_LONGS(map_size)));
8785+
sip->map_storep = vcalloc(BITS_TO_LONGS(map_size),
8786+
sizeof(long));
87878787

87888788
pr_info("%lu provisioning blocks\n", map_size);
87898789

@@ -8792,8 +8792,6 @@ static int sdebug_add_store(void)
87928792
goto err;
87938793
}
87948794

8795-
bitmap_zero(sip->map_storep, map_size);
8796-
87978795
/* Map first 1KB for partition table */
87988796
if (sdebug_num_parts)
87998797
map_region(sip, 0, 2);

0 commit comments

Comments
 (0)