]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
scsi: pm80xx: Set phy->enable_completion only when we
authorIgor Pylypiv <ipylypiv@google.com>
Fri, 28 Nov 2025 14:48:15 +0000 (17:48 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 6 Dec 2025 21:12:45 +0000 (06:12 +0900)
[ Upstream commit e4f949ef1516c0d74745ee54a0f4882c1f6c7aea ]

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>
drivers/scsi/pm8001/pm8001_sas.c

index 00d70b458b48c4d96153f74bec2545438d5b78e1..4cd648be68dde47e537e72f39a72ada3600ca039 100644 (file)
@@ -168,7 +168,6 @@ int pm8001_phy_control(struct asd_sas_phy *sas_phy, enum phy_func func,
        unsigned long flags;
        pm8001_ha = sas_phy->ha->lldd_ha;
        phy = &pm8001_ha->phy[phy_id];
-       pm8001_ha->phy[phy_id].enable_completion = &completion;
        switch (func) {
        case PHY_FUNC_SET_LINK_RATE:
                rates = funcdata;
@@ -181,6 +180,7 @@ int pm8001_phy_control(struct asd_sas_phy *sas_phy, enum phy_func func,
                                rates->maximum_linkrate;
                }
                if (pm8001_ha->phy[phy_id].phy_state ==  PHY_LINK_DISABLE) {
+                       pm8001_ha->phy[phy_id].enable_completion = &completion;
                        PM8001_CHIP_DISP->phy_start_req(pm8001_ha, phy_id);
                        wait_for_completion(&completion);
                }
@@ -189,6 +189,7 @@ int pm8001_phy_control(struct asd_sas_phy *sas_phy, enum phy_func func,
                break;
        case PHY_FUNC_HARD_RESET:
                if (pm8001_ha->phy[phy_id].phy_state == PHY_LINK_DISABLE) {
+                       pm8001_ha->phy[phy_id].enable_completion = &completion;
                        PM8001_CHIP_DISP->phy_start_req(pm8001_ha, phy_id);
                        wait_for_completion(&completion);
                }
@@ -197,6 +198,7 @@ int pm8001_phy_control(struct asd_sas_phy *sas_phy, enum phy_func func,
                break;
        case PHY_FUNC_LINK_RESET:
                if (pm8001_ha->phy[phy_id].phy_state == PHY_LINK_DISABLE) {
+                       pm8001_ha->phy[phy_id].enable_completion = &completion;
                        PM8001_CHIP_DISP->phy_start_req(pm8001_ha, phy_id);
                        wait_for_completion(&completion);
                }