pds_core: quiesce DMA before freeing resources
Subsystems (3)
PATCH v2 1/1 pds_core: quiesce DMA before freeing resources
pdsc_teardown() frees DMA buffers but does not disable bus mastering, leaving the device able to perform DMA after the buffers are freed. This can lead to use-after-free if the device writes to freed memory.
Add pci_clear_master() to pdsc_teardown() to disable bus mastering before freeing resources, ensuring all DMA is quiesced.
Add pci_set_master() to pdsc_setup() to re-enable bus mastering, which is needed for the firmware recovery path since pdsc_teardown() now disables it.
---
v2:
- Move pci_clear_master() from pdsc_stop() to pdsc_teardown() to cover error paths (Sashiko)
- Add pci_set_master() to pdsc_setup() instead of pdsc_start() for
recovery path (Sashiko)
- Drop Reviewed-by since patch changed substantially
v1: https://lore.kernel.org/netdev/[email protected]/
Sashiko review: https://sashiko.dev/#/patchset/20260603035245.32972-1-nikhil.rao%40amd.com
drivers/net/ethernet/amd/pds_core/core.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/ethernet/amd/pds_core/core.c +4 -0
@@ -446,6 +446,8 @@ int pdsc_setup(struct pdsc *pdsc, bool init) {int err; +pci_set_master (pdsc->pdev); + err =pdsc_dev_init (pdsc);if (err)return err;
@@ -480,6 +482,8 @@ void pdsc_teardown(struct pdsc *pdsc, bool removing)if (pdsc->adminqcq.work.func)cancel_work_sync (&pdsc->adminqcq.work); +pci_clear_master (pdsc->pdev); +pdsc_core_uninit (pdsc);if (removing) {
Signature · 1 line
2.43.0
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 8 lines · On Thu, 4 Jun 2026 21:36:37 +0000 you wrote:
pdsc_teardown()frees DMA buffers but does not disable bus mastering, leaving the device able to perform DMA after the buffers are freed. This can lead to use-after-free if the device writes to freed memory.Add
pci_clear_master()topdsc_teardown()to disable bus mastering before freeing resources, ensuring all DMA is quiesced.[...]
Here is the summary with links:
- [net,v2] pds_core: quiesce DMA before freeing resources
https://git.kernel.org/netdev/net-next/c/6443f4f20bda
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html