Skip to content

Commit 3b01d7e

Browse files
dinghaoliumartinkpetersen
authored andcommitted
scsi: scsi_debug: Fix memleak in scsi_debug_init()
When sdeb_zbc_model does not match BLK_ZONED_NONE, BLK_ZONED_HA or BLK_ZONED_HM, we should free sdebug_q_arr to prevent memleak. Also there is no need to execute sdebug_erase_store() on failure of sdeb_zbc_model_str(). Link: https://lore.kernel.org/r/[email protected] Acked-by: Douglas Gilbert <[email protected]> Signed-off-by: Dinghao Liu <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 39718fe commit 3b01d7e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

drivers/scsi/scsi_debug.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6740,7 +6740,7 @@ static int __init scsi_debug_init(void)
67406740
k = sdeb_zbc_model_str(sdeb_zbc_model_s);
67416741
if (k < 0) {
67426742
ret = k;
6743-
goto free_vm;
6743+
goto free_q_arr;
67446744
}
67456745
sdeb_zbc_model = k;
67466746
switch (sdeb_zbc_model) {
@@ -6753,7 +6753,8 @@ static int __init scsi_debug_init(void)
67536753
break;
67546754
default:
67556755
pr_err("Invalid ZBC model\n");
6756-
return -EINVAL;
6756+
ret = -EINVAL;
6757+
goto free_q_arr;
67576758
}
67586759
}
67596760
if (sdeb_zbc_model != BLK_ZONED_NONE) {

0 commit comments

Comments
 (0)