scsi: pm80xx: Set phy->enable_completion only when we wait for it
authorIgor Pylypiv <ipylypiv@google.com>
Thu, 27 Jun 2024 15:59:23 +0000 (15:59 +0000)
committerMartin K. Petersen <martin.petersen@oracle.com>
Fri, 5 Jul 2024 02:53:13 +0000 (22:53 -0400)
commite4f949ef1516c0d74745ee54a0f4882c1f6c7aea
treeaa457fe6ae27b130c558fcb7d7005b3c6b8ff4f9
parent7cbff570dbe8907e23bba06f6414899a0fbb2fcc
scsi: pm80xx: Set phy->enable_completion only when we wait for it

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