summaryrefslogtreecommitdiffstats
path: root/drivers/scsi/pm8001
diff options
context:
space:
mode:
authorDamien Le Moal <damien.lemoal@opensource.wdc.com>2022-02-20 04:17:56 +0100
committerMartin K. Petersen <martin.petersen@oracle.com>2022-02-23 03:31:19 +0100
commitf17c599a44fca3d04bd1bed3f452c104d9e48cab (patch)
tree83814c9ea751d30a000e04978b84b10c555ad032 /drivers/scsi/pm8001
parentscsi: pm8001: Fix abort all task initialization (diff)
downloadlinux-f17c599a44fca3d04bd1bed3f452c104d9e48cab.tar.xz
linux-f17c599a44fca3d04bd1bed3f452c104d9e48cab.zip
scsi: pm8001: Fix pm8001_tag_alloc() failures handling
In mpi_set_phy_profile_req() and in pm8001_set_phy_profile_single(), if pm8001_tag_alloc() fails to allocate a new tag, a warning message is issued but the uninitialized tag variable is still used to build a command. Avoid this by returning early in case of tag allocation failure. Also make sure to always return the error code returned by pm8001_tag_alloc() when this function fails instead of an arbitrary value. Link: https://lore.kernel.org/r/20220220031810.738362-18-damien.lemoal@opensource.wdc.com Reviewed-by: John Garry <john.garry@huawei.com> Reviewed-by: Jack Wang <jinpu.wang@ionos.com> Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'drivers/scsi/pm8001')
-rw-r--r--drivers/scsi/pm8001/pm80xx_hwi.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c
index 8fd38e54f07c..76260d06b6be 100644
--- a/drivers/scsi/pm8001/pm80xx_hwi.c
+++ b/drivers/scsi/pm8001/pm80xx_hwi.c
@@ -1191,7 +1191,7 @@ pm80xx_set_thermal_config(struct pm8001_hba_info *pm8001_ha)
memset(&payload, 0, sizeof(struct set_ctrl_cfg_req));
rc = pm8001_tag_alloc(pm8001_ha, &tag);
if (rc)
- return -1;
+ return rc;
circularQ = &pm8001_ha->inbnd_q_tbl[0];
payload.tag = cpu_to_le32(tag);
@@ -1240,7 +1240,7 @@ pm80xx_set_sas_protocol_timer_config(struct pm8001_hba_info *pm8001_ha)
rc = pm8001_tag_alloc(pm8001_ha, &tag);
if (rc)
- return -1;
+ return rc;
circularQ = &pm8001_ha->inbnd_q_tbl[0];
payload.tag = cpu_to_le32(tag);
@@ -1398,7 +1398,7 @@ static int pm80xx_encrypt_update(struct pm8001_hba_info *pm8001_ha)
memset(&payload, 0, sizeof(struct kek_mgmt_req));
rc = pm8001_tag_alloc(pm8001_ha, &tag);
if (rc)
- return -1;
+ return rc;
circularQ = &pm8001_ha->inbnd_q_tbl[0];
payload.tag = cpu_to_le32(tag);
@@ -4967,8 +4967,11 @@ static void mpi_set_phy_profile_req(struct pm8001_hba_info *pm8001_ha,
memset(&payload, 0, sizeof(payload));
rc = pm8001_tag_alloc(pm8001_ha, &tag);
- if (rc)
+ if (rc) {
pm8001_dbg(pm8001_ha, FAIL, "Invalid tag\n");
+ return;
+ }
+
circularQ = &pm8001_ha->inbnd_q_tbl[0];
payload.tag = cpu_to_le32(tag);
payload.ppc_phyid =
@@ -5010,8 +5013,10 @@ void pm8001_set_phy_profile_single(struct pm8001_hba_info *pm8001_ha,
memset(&payload, 0, sizeof(payload));
rc = pm8001_tag_alloc(pm8001_ha, &tag);
- if (rc)
+ if (rc) {
pm8001_dbg(pm8001_ha, INIT, "Invalid tag\n");
+ return;
+ }
circularQ = &pm8001_ha->inbnd_q_tbl[0];
opc = OPC_INB_SET_PHY_PROFILE;