Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Damien Le Moal and committed by
Martin K. Petersen
f17c599a 7f12845c

+10 -5
+10 -5
drivers/scsi/pm8001/pm80xx_hwi.c
··· 1191 1191 memset(&payload, 0, sizeof(struct set_ctrl_cfg_req)); 1192 1192 rc = pm8001_tag_alloc(pm8001_ha, &tag); 1193 1193 if (rc) 1194 - return -1; 1194 + return rc; 1195 1195 1196 1196 circularQ = &pm8001_ha->inbnd_q_tbl[0]; 1197 1197 payload.tag = cpu_to_le32(tag); ··· 1240 1240 rc = pm8001_tag_alloc(pm8001_ha, &tag); 1241 1241 1242 1242 if (rc) 1243 - return -1; 1243 + return rc; 1244 1244 1245 1245 circularQ = &pm8001_ha->inbnd_q_tbl[0]; 1246 1246 payload.tag = cpu_to_le32(tag); ··· 1398 1398 memset(&payload, 0, sizeof(struct kek_mgmt_req)); 1399 1399 rc = pm8001_tag_alloc(pm8001_ha, &tag); 1400 1400 if (rc) 1401 - return -1; 1401 + return rc; 1402 1402 1403 1403 circularQ = &pm8001_ha->inbnd_q_tbl[0]; 1404 1404 payload.tag = cpu_to_le32(tag); ··· 4967 4967 4968 4968 memset(&payload, 0, sizeof(payload)); 4969 4969 rc = pm8001_tag_alloc(pm8001_ha, &tag); 4970 - if (rc) 4970 + if (rc) { 4971 4971 pm8001_dbg(pm8001_ha, FAIL, "Invalid tag\n"); 4972 + return; 4973 + } 4974 + 4972 4975 circularQ = &pm8001_ha->inbnd_q_tbl[0]; 4973 4976 payload.tag = cpu_to_le32(tag); 4974 4977 payload.ppc_phyid = ··· 5013 5010 memset(&payload, 0, sizeof(payload)); 5014 5011 5015 5012 rc = pm8001_tag_alloc(pm8001_ha, &tag); 5016 - if (rc) 5013 + if (rc) { 5017 5014 pm8001_dbg(pm8001_ha, INIT, "Invalid tag\n"); 5015 + return; 5016 + } 5018 5017 5019 5018 circularQ = &pm8001_ha->inbnd_q_tbl[0]; 5020 5019 opc = OPC_INB_SET_PHY_PROFILE;