Skip to content

switchtec: Fix stdev_release crash after suprise device loss.

Daniel Stodden linux-pci 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest1 patch 0 repliesNew

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/1switchtec: Fix stdev_release crash after suprise device loss.drivers/pci/switch/switchtec.c+21 -80 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/1] switchtec: Fix stdev_release crash after suprise device loss.

Hello.

Here goes a small shell script to crash a kernel in switchtec.ko's stdev_release.

--snip--
#!/bin/bash -x

# open cdev
exec 3<>/dev/switchtec0
# remove pdev
addr=$(basename $(realpath /sys/class/switchtec/switchtec0/../..))
echo 1 > /sys/bus/pci/devices/$addr/remove
# close cdev
exec 3>&-
--snip--

It worked on v5.10. I believe it has been working ever since. The problem is that keeping the stdev pinned past the pci_driver removal will defer the mrpc dma shutdown until way after devres_release_all, which unmapped stdev->mmio_mrpc. Also, stdev->pdev would be a stale pointer by then.

Followed-up with a humble proposal how to fix it.

Thanks,
Daniel

Daniel Stodden (1):
switchtec: Fix stdev_release crash after suprise device loss.

 drivers/pci/switch/switchtec.c | 29 +++++++++++++++++++++--------
 1 file changed, 21 insertions(+), 8 deletions(-)
Signature · 1 line
2.41.0