Skip to content

Commit e23ee0c

Browse files
ipylypivgregkh
authored andcommitted
scsi: pm80xx: Set phy->enable_completion only when we
[ Upstream commit e4f949e ] pm8001_phy_control() populates the enable_completion pointer with a stack address, sends a PHY_LINK_RESET / PHY_HARD_RESET, waits 300 ms, and returns. The problem arises when a phy control response comes late. After 300 ms the pm8001_phy_control() function returns and the passed enable_completion stack address is no longer valid. Late phy control response invokes complete() on a dangling enable_completion pointer which leads to a kernel crash. Signed-off-by: Igor Pylypiv <ipylypiv@google.com> Signed-off-by: Terrence Adams <tadamsjr@google.com> Link: https://lore.kernel.org/r/20240627155924.2361370-2-tadamsjr@google.com Acked-by: Jack Wang <jinpu.wang@ionos.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Nazar Kalashnikov <sivartiwe@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent c12a0c3 commit e23ee0c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/scsi/pm8001/pm8001_sas.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,6 @@ int pm8001_phy_control(struct asd_sas_phy *sas_phy, enum phy_func func,
168168
unsigned long flags;
169169
pm8001_ha = sas_phy->ha->lldd_ha;
170170
phy = &pm8001_ha->phy[phy_id];
171-
pm8001_ha->phy[phy_id].enable_completion = &completion;
172171
switch (func) {
173172
case PHY_FUNC_SET_LINK_RATE:
174173
rates = funcdata;
@@ -181,6 +180,7 @@ int pm8001_phy_control(struct asd_sas_phy *sas_phy, enum phy_func func,
181180
rates->maximum_linkrate;
182181
}
183182
if (pm8001_ha->phy[phy_id].phy_state == PHY_LINK_DISABLE) {
183+
pm8001_ha->phy[phy_id].enable_completion = &completion;
184184
PM8001_CHIP_DISP->phy_start_req(pm8001_ha, phy_id);
185185
wait_for_completion(&completion);
186186
}
@@ -189,6 +189,7 @@ int pm8001_phy_control(struct asd_sas_phy *sas_phy, enum phy_func func,
189189
break;
190190
case PHY_FUNC_HARD_RESET:
191191
if (pm8001_ha->phy[phy_id].phy_state == PHY_LINK_DISABLE) {
192+
pm8001_ha->phy[phy_id].enable_completion = &completion;
192193
PM8001_CHIP_DISP->phy_start_req(pm8001_ha, phy_id);
193194
wait_for_completion(&completion);
194195
}
@@ -197,6 +198,7 @@ int pm8001_phy_control(struct asd_sas_phy *sas_phy, enum phy_func func,
197198
break;
198199
case PHY_FUNC_LINK_RESET:
199200
if (pm8001_ha->phy[phy_id].phy_state == PHY_LINK_DISABLE) {
201+
pm8001_ha->phy[phy_id].enable_completion = &completion;
200202
PM8001_CHIP_DISP->phy_start_req(pm8001_ha, phy_id);
201203
wait_for_completion(&completion);
202204
}

0 commit comments

Comments
 (0)