From: Nikhil P. Rao Date: Thu, 4 Jun 2026 21:36:37 +0000 (+0000) Subject: pds_core: quiesce DMA before freeing resources X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6443f4f20bdae726fe01cf5946fba9742a0ffda6;p=thirdparty%2Flinux.git 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. Signed-off-by: Nikhil P. Rao Link: https://patch.msgid.link/20260604213637.3844317-1-nikhil.rao@amd.com Signed-off-by: Jakub Kicinski --- diff --git a/drivers/net/ethernet/amd/pds_core/core.c b/drivers/net/ethernet/amd/pds_core/core.c index 705cab7b07273..38a2446571afa 100644 --- a/drivers/net/ethernet/amd/pds_core/core.c +++ b/drivers/net/ethernet/amd/pds_core/core.c @@ -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) {