Skip to content

Commit 43c617e

Browse files
Damien Le Moalgregkh
authored andcommitted
scsi: pm8001: Fix tag leaks on error
[ Upstream commit 4c8f04b ] In pm8001_chip_set_dev_state_req(), pm8001_chip_fw_flash_update_req(), pm80xx_chip_phy_ctl_req() and pm8001_chip_reg_dev_req() add missing calls to pm8001_tag_free() to free the allocated tag when pm8001_mpi_build_cmd() fails. Similarly, in pm8001_exec_internal_task_abort(), if the chip ->task_abort method fails, the tag allocated for the abort request task must be freed. Add the missing call to pm8001_tag_free(). Link: https://lore.kernel.org/r/20220220031810.738362-22-damien.lemoal@opensource.wdc.com Reviewed-by: John Garry <john.garry@huawei.com> Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 2290dca commit 43c617e

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

drivers/scsi/pm8001/pm8001_hwi.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4488,6 +4488,9 @@ static int pm8001_chip_reg_dev_req(struct pm8001_hba_info *pm8001_ha,
44884488
SAS_ADDR_SIZE);
44894489
rc = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload,
44904490
sizeof(payload), 0);
4491+
if (rc)
4492+
pm8001_tag_free(pm8001_ha, tag);
4493+
44914494
return rc;
44924495
}
44934496

@@ -4900,6 +4903,9 @@ pm8001_chip_fw_flash_update_req(struct pm8001_hba_info *pm8001_ha,
49004903
ccb->ccb_tag = tag;
49014904
rc = pm8001_chip_fw_flash_update_build(pm8001_ha, &flash_update_info,
49024905
tag);
4906+
if (rc)
4907+
pm8001_tag_free(pm8001_ha, tag);
4908+
49034909
return rc;
49044910
}
49054911

@@ -5004,6 +5010,9 @@ pm8001_chip_set_dev_state_req(struct pm8001_hba_info *pm8001_ha,
50045010
payload.nds = cpu_to_le32(state);
50055011
rc = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload,
50065012
sizeof(payload), 0);
5013+
if (rc)
5014+
pm8001_tag_free(pm8001_ha, tag);
5015+
50075016
return rc;
50085017

50095018
}

drivers/scsi/pm8001/pm8001_sas.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -831,10 +831,10 @@ pm8001_exec_internal_task_abort(struct pm8001_hba_info *pm8001_ha,
831831

832832
res = PM8001_CHIP_DISP->task_abort(pm8001_ha,
833833
pm8001_dev, flag, task_tag, ccb_tag);
834-
835834
if (res) {
836835
del_timer(&task->slow_task->timer);
837836
pm8001_dbg(pm8001_ha, FAIL, "Executing internal task failed\n");
837+
pm8001_tag_free(pm8001_ha, ccb_tag);
838838
goto ex_err;
839839
}
840840
wait_for_completion(&task->slow_task->completion);

drivers/scsi/pm8001/pm80xx_hwi.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4920,8 +4920,13 @@ static int pm80xx_chip_phy_ctl_req(struct pm8001_hba_info *pm8001_ha,
49204920
payload.tag = cpu_to_le32(tag);
49214921
payload.phyop_phyid =
49224922
cpu_to_le32(((phy_op & 0xFF) << 8) | (phyId & 0xFF));
4923-
return pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload,
4924-
sizeof(payload), 0);
4923+
4924+
rc = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload,
4925+
sizeof(payload), 0);
4926+
if (rc)
4927+
pm8001_tag_free(pm8001_ha, tag);
4928+
4929+
return rc;
49254930
}
49264931

49274932
static u32 pm80xx_chip_is_our_interrupt(struct pm8001_hba_info *pm8001_ha)

0 commit comments

Comments
 (0)