* [PATCH] RDMA/nldev: Put the device when dellink fails
@ 2026-09-03 8:25 lirongqing
0 siblings, 0 replies; only message in thread
From: lirongqing @ 2026-09-03 8:25 UTC (permalink / raw)
To: Jason Gunthorpe, Leon Romanovsky, Patrisious Haddad, Jiri Pirko,
Edward Srouji, Michael Guralnik, Tao Cui, Erni Sri Satya Vennela,
Michael Margolin, David Ahern, Zhu Yanjun, linux-rdma
Cc: Li RongQing
From: Li RongQing <lirongqing@baidu.com>
nldev_dellink() takes a device reference through
ib_device_get_by_index() and normally hands it over to
ib_unregister_device_and_put(). The error path of the ->dellink
callback returns without releasing it, so the reference is leaked.
Once that happens, any later unregistration of the device blocks
forever, because disable_device() drops its own reference and then
waits for the refcount to drain. No in-tree driver returns an error
from ->dellink today, so the leak is currently latent.
Put the device before returning the error.
Fixes: a60e3f3d6fba ("RDMA/nldev: Add dellink function pointer")
Signed-off-by: Li RongQing <lirongqing@baidu.com>
---
drivers/infiniband/core/nldev.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/infiniband/core/nldev.c b/drivers/infiniband/core/nldev.c
index a4014a2..a1542ed 100644
--- a/drivers/infiniband/core/nldev.c
+++ b/drivers/infiniband/core/nldev.c
@@ -1895,8 +1895,10 @@ static int nldev_dellink(struct sk_buff *skb, struct nlmsghdr *nlh,
mutex_lock(&nldev_dellink_mutex);
err = device->link_ops->dellink(device);
mutex_unlock(&nldev_dellink_mutex);
- if (err)
+ if (err) {
+ ib_device_put(device);
return err;
+ }
}
ib_unregister_device_and_put(device);
--
2.9.4
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-09-03 8:28 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-03 8:25 [PATCH] RDMA/nldev: Put the device when dellink fails lirongqing
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox