mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] [v2] scsi: scsi_debug: Fix memleak in scsi_debug_init
@ 2020-12-26  6:15 Dinghao Liu
  2020-12-27  0:46 ` Douglas Gilbert
  2021-01-08  4:19 ` Martin K. Petersen
  0 siblings, 2 replies; 3+ messages in thread
From: Dinghao Liu @ 2020-12-26  6:15 UTC (permalink / raw)
  To: dinghao.liu, kjlu
  Cc: James E.J. Bottomley, Martin K. Petersen, linux-scsi, linux-kernel

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().

Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
---

Changelog:

v2: - Add missed assignment statement for ret.
---
 drivers/scsi/scsi_debug.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index 24c0f7ec0351..4a08c450b756 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -6740,7 +6740,7 @@ static int __init scsi_debug_init(void)
 		k = sdeb_zbc_model_str(sdeb_zbc_model_s);
 		if (k < 0) {
 			ret = k;
-			goto free_vm;
+			goto free_q_arr;
 		}
 		sdeb_zbc_model = k;
 		switch (sdeb_zbc_model) {
@@ -6753,7 +6753,8 @@ static int __init scsi_debug_init(void)
 			break;
 		default:
 			pr_err("Invalid ZBC model\n");
-			return -EINVAL;
+			ret = -EINVAL;
+			goto free_q_arr;
 		}
 	}
 	if (sdeb_zbc_model != BLK_ZONED_NONE) {
-- 
2.17.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-01-08  4:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-26  6:15 [PATCH] [v2] scsi: scsi_debug: Fix memleak in scsi_debug_init Dinghao Liu
2020-12-27  0:46 ` Douglas Gilbert
2021-01-08  4:19 ` Martin K. Petersen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®