[PATCH 5.10] RDMA/hfi1: shut down the trap timer before unregistering

From: Alexander Martyniuk

Date: Tue Dec 01 2026 - 10:01:18 EST


From: Hongyan Xu <getshell@xxxxxxxxxx>

commit a1c9d476c2316685f85fffb6450ad88d01836357 upstream.

MAD processing arms a trap timer embedded in each hfi1_ibport. Device
unregistration does not stop the timer, so its callback can run after
the port and its containing hfi1_devdata have been released.

Shut down every port timer before unregistering the IB device. The
shutdown form also prevents a concurrent path from rearming the timer.

Fixes: bf90aadd630c ("IB/hfi1: Send MAD traps until repressed")
Signed-off-by: Hongyan Xu <getshell@xxxxxxxxxx>
Link: https://patch.msgid.link/20260928134151.1213-1-getshell@xxxxxxxxxx
Signed-off-by: Leon Romanovsky <leon@xxxxxxxxxx>
[Alexander: del_timer_sync() used instead of the timer_shutdown_sync()]
Signed-off-by: Alexander Martyniuk <alexevgmart@xxxxxxxxx>
---
Backport fix for CVE-2026-139571
drivers/infiniband/hw/hfi1/verbs.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/drivers/infiniband/hw/hfi1/verbs.c b/drivers/infiniband/hw/hfi1/verbs.c
index 693922df3543..06cb57da73b2 100644
--- a/drivers/infiniband/hw/hfi1/verbs.c
+++ b/drivers/infiniband/hw/hfi1/verbs.c
@@ -1950,6 +1950,10 @@ int hfi1_register_ib_device(struct hfi1_devdata *dd)
void hfi1_unregister_ib_device(struct hfi1_devdata *dd)
{
struct hfi1_ibdev *dev = &dd->verbs_dev;
+ int i;
+
+ for (i = 0; i < dd->num_pports; i++)
+ del_timer_sync(&dd->pport[i].ibport_data.rvp.trap_timer);

hfi1_verbs_unregister_sysfs(dd);

--
2.43.0