[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20220401073833.15655-1-niejianglei2021@163.com>
Date: Fri, 1 Apr 2022 15:38:33 +0800
From: Jianglei Nie <niejianglei2021@....com>
To: jinpu.wang@...ud.ionos.com, jejb@...ux.ibm.com,
martin.petersen@...cle.com
Cc: nlinux-scsi@...r.kernel.org, linux-kernel@...r.kernel.org,
Jianglei Nie <niejianglei2021@....com>
Subject: [PATCH] scsi: pm8001: Fix resource leak in pm8001_send_abort_all()
sas_alloc_slow_task() allocates a task in line 1774. But when
pm8001_tag_alloc() or pm8001_mpi_build_cmd() fail, the allocated task
is not freed by sas_free_task(), which will lead to resource leak.
We can fix it by freeing the task when pm8001_tag_alloc() and
pm8001_mpi_build_cmd() fail.
Signed-off-by: Jianglei Nie <niejianglei2021@....com>
---
drivers/scsi/pm8001/pm8001_hwi.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c
index 9ec310b795c3..fec5e26fbf0f 100644
--- a/drivers/scsi/pm8001/pm8001_hwi.c
+++ b/drivers/scsi/pm8001/pm8001_hwi.c
@@ -1781,8 +1781,10 @@ static void pm8001_send_abort_all(struct pm8001_hba_info *pm8001_ha,
task->task_done = pm8001_task_done;
res = pm8001_tag_alloc(pm8001_ha, &ccb_tag);
- if (res)
+ if (res) {
+ sas_free_task(task);
return;
+ }
ccb = &pm8001_ha->ccb_info[ccb_tag];
ccb->device = pm8001_ha_dev;
@@ -1798,9 +1800,10 @@ static void pm8001_send_abort_all(struct pm8001_hba_info *pm8001_ha,
ret = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &task_abort,
sizeof(task_abort), 0);
- if (ret)
+ if (ret) {
+ sas_free_task(task);
pm8001_tag_free(pm8001_ha, ccb_tag);
-
+ }
}
static void pm8001_send_read_log(struct pm8001_hba_info *pm8001_ha,
--
2.25.1
Powered by blists - more mailing lists