[LTP] [PATCH] Revert "tpci: unbind driver in test_assign_resources()"

Hongtao Zhang zhanghongtao35@huawei.com
Tue Jul 14 11:06:32 CEST 2026


While the patch fixes a use-after-free in /proc/iomem by unbinding and
rebinding the driver around PCI resource reassignment, this approach is
too dangerous for a general test. Unbinding a driver from a critical device
(e.g. a network or block controller) can instantly break SSH connectivity or
cause filesystem corruption. Such side effects are unacceptable compared to the original issue.
So need to revert that patch.

Signed-off-by: Hongtao Zhang <zhanghongtao35@huawei.com>
---
 .../device-drivers/pci/tpci_kernel/ltp_tpci.c     | 15 ---------------
 1 file changed, 15 deletions(-)

diff --git a/testcases/kernel/device-drivers/pci/tpci_kernel/ltp_tpci.c b/testcases/kernel/device-drivers/pci/tpci_kernel/ltp_tpci.c
index 45138d834..660b3a423 100644
--- a/testcases/kernel/device-drivers/pci/tpci_kernel/ltp_tpci.c
+++ b/testcases/kernel/device-drivers/pci/tpci_kernel/ltp_tpci.c
@@ -442,24 +442,9 @@ static int test_assign_resources(void)
 
 		if (r->flags & IORESOURCE_MEM &&
 			r->flags & IORESOURCE_PREFETCH) {
-
-			if (dev->hdr_type == PCI_HEADER_TYPE_NORMAL) {
-				if (dev->dev.driver)
-					device_release_driver(&dev->dev);
-			}
-
 			pci_release_resource(dev, i);
 			ret = pci_assign_resource(dev, i);
 			prk_info("assign resource to '%d', ret '%d'", i, ret);
-
-			if (ret == 0 && dev->hdr_type == PCI_HEADER_TYPE_NORMAL) {
-				int attach_ret;
-
-				attach_ret = device_attach(&dev->dev);
-				if (attach_ret < 0)
-					prk_info("device_attach failed for endpoint, ret: %d", attach_ret);
-			}
-
 			rc |= (ret < 0 && ret != -EBUSY) ? TFAIL : TPASS;
 		}
 	}
-- 
2.43.0



More information about the ltp mailing list