Commit df25461
PCI: switchtec: Fix stdev_release() crash after surprise hot remove
A PCI device hot removal may occur while stdev->cdev is held open. The call
to stdev_release() then happens during close or exit, at a point way past
switchtec_pci_remove(). Otherwise the last ref would vanish with the
trailing put_device(), just before return.
At that later point in time, the devm cleanup has already removed the
stdev->mmio_mrpc mapping. Also, the stdev->pdev reference was not a counted
one. Therefore, in DMA mode, the iowrite32() in stdev_release() will cause
a fatal page fault, and the subsequent dma_free_coherent(), if reached,
would pass a stale &stdev->pdev->dev pointer.
Fix by moving MRPC DMA shutdown into switchtec_pci_remove(), after
stdev_kill(). Counting the stdev->pdev ref is now optional, but may prevent
future accidents.
Reproducible via the script at
https://lore.kernel.org/r/[email protected]
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Daniel Stodden <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
Reviewed-by: Logan Gunthorpe <[email protected]>
Reviewed-by: Dmitry Safonov <[email protected]>1 parent b85ea95 commit df25461
1 file changed
+17
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1308 | 1308 | | |
1309 | 1309 | | |
1310 | 1310 | | |
1311 | | - | |
1312 | | - | |
1313 | | - | |
1314 | | - | |
1315 | | - | |
1316 | | - | |
1317 | | - | |
1318 | 1311 | | |
1319 | 1312 | | |
1320 | 1313 | | |
| |||
1358 | 1351 | | |
1359 | 1352 | | |
1360 | 1353 | | |
1361 | | - | |
| 1354 | + | |
1362 | 1355 | | |
1363 | 1356 | | |
1364 | 1357 | | |
| |||
1391 | 1384 | | |
1392 | 1385 | | |
1393 | 1386 | | |
| 1387 | + | |
1394 | 1388 | | |
1395 | 1389 | | |
1396 | 1390 | | |
| |||
1644 | 1638 | | |
1645 | 1639 | | |
1646 | 1640 | | |
| 1641 | + | |
| 1642 | + | |
| 1643 | + | |
| 1644 | + | |
| 1645 | + | |
| 1646 | + | |
| 1647 | + | |
| 1648 | + | |
| 1649 | + | |
| 1650 | + | |
| 1651 | + | |
| 1652 | + | |
1647 | 1653 | | |
1648 | 1654 | | |
1649 | 1655 | | |
| |||
1703 | 1709 | | |
1704 | 1710 | | |
1705 | 1711 | | |
| 1712 | + | |
| 1713 | + | |
| 1714 | + | |
1706 | 1715 | | |
1707 | 1716 | | |
1708 | 1717 | | |
| |||
0 commit comments