]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
scsi: scsi_debug: Use vcalloc() to simplify code
authorQianfeng Rong <rongqianfeng@vivo.com>
Wed, 6 Aug 2025 12:46:33 +0000 (20:46 +0800)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 20 Aug 2025 01:56:23 +0000 (21:56 -0400)
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>
drivers/scsi/scsi_debug.c

index 0847767d4d4361bf8ab27026aa2149b555e8ea4d..90943857243c1e0b13b38ec8e5271a32c9f45aeb 100644 (file)
@@ -8782,8 +8782,8 @@ static int sdebug_add_store(void)
        /* Logical Block Provisioning */
        if (scsi_debug_lbp()) {
                map_size = lba_to_map_index(sdebug_store_sectors - 1) + 1;
-               sip->map_storep = vmalloc(array_size(sizeof(long),
-                                                    BITS_TO_LONGS(map_size)));
+               sip->map_storep = vcalloc(BITS_TO_LONGS(map_size),
+                                         sizeof(long));
 
                pr_info("%lu provisioning blocks\n", map_size);
 
@@ -8792,8 +8792,6 @@ static int sdebug_add_store(void)
                        goto err;
                }
 
-               bitmap_zero(sip->map_storep, map_size);
-
                /* Map first 1KB for partition table */
                if (sdebug_num_parts)
                        map_region(sip, 0, 2);