In mvumi_probe_devices(), an internal command cmd is allocated via
mvumi_create_internal_cmd() at the beginning of the function.
This command is used within a loop that calls mvumi_match_devices(). If
a device conflict is detected, the function exits immediately without
freeing the cmd allocated at the start, leading to a memory leak.
Fix this by calling mvumi_delete_internal_cmd() to release the command
before returning in this error path.
Fixes: bd756ddea18e0 ("[SCSI] mvumi: Add support for Marvell SAS/SATA RAID-on-Chip(ROC) 88RC9580")
Signed-off-by: Zilin Guan <zilin@seu.edu.cn>
---
drivers/scsi/mvumi.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/scsi/mvumi.c b/drivers/scsi/mvumi.c
index bdc2f2f17753..9a721608ccea 100644
--- a/drivers/scsi/mvumi.c
+++ b/drivers/scsi/mvumi.c
@@ -1589,10 +1589,12 @@ static int mvumi_probe_devices(struct mvumi_hba *mhba)
dev_dbg(&mhba->pdev->dev,
"probe a new device(0:%d:0)"
" wwid(%llx)\n", id, mv_dev->wwid);
- } else if (found == -1)
+ } else if (found == -1) {
+ mvumi_delete_internal_cmd(mhba, cmd);
return -1;
- else
+ } else {
continue;
+ }
}
}
--
2.34.1