* [PATCH] RDMA/nldev: Fix ib_device reference leak in nldev_dellink()
@ 2026-09-16 18:31 Wentao Liang
2026-09-23 8:32 ` Leon Romanovsky
0 siblings, 1 reply; 2+ messages in thread
From: Wentao Liang @ 2026-09-16 18:31 UTC (permalink / raw)
To: dsahern
Cc: jgg, leon, linux-kernel, linux-rdma, yanjun.zhu, Wentao Liang, stable
nldev_dellink() takes a reference on the ib_device with
ib_device_get_by_index(). When the driver's dellink callback fails,
the function returns the error directly without dropping that
reference, leaking it. Call ib_device_put() on the dellink error
path before returning, matching the handling of the other error
exits in this function.
Fixes: a60e3f3d6fba ("RDMA/nldev: Add dellink function pointer")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
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 5aaba2b9746b..e4a9562313fa 100644
--- a/drivers/infiniband/core/nldev.c
+++ b/drivers/infiniband/core/nldev.c
@@ -1850,8 +1850,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.34.1
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] RDMA/nldev: Fix ib_device reference leak in nldev_dellink()
2026-09-16 18:31 [PATCH] RDMA/nldev: Fix ib_device reference leak in nldev_dellink() Wentao Liang
@ 2026-09-23 8:32 ` Leon Romanovsky
0 siblings, 0 replies; 2+ messages in thread
From: Leon Romanovsky @ 2026-09-23 8:32 UTC (permalink / raw)
To: Wentao Liang; +Cc: dsahern, jgg, linux-kernel, linux-rdma, yanjun.zhu, stable
On Wed, Sep 16, 2026 at 06:31:01PM +0000, Wentao Liang wrote:
> nldev_dellink() takes a reference on the ib_device with
> ib_device_get_by_index(). When the driver's dellink callback fails,
> the function returns the error directly without dropping that
> reference, leaking it. Call ib_device_put() on the dellink error
> path before returning, matching the handling of the other error
> exits in this function.
>
> Fixes: a60e3f3d6fba ("RDMA/nldev: Add dellink function pointer")
> Cc: stable@vger.kernel.org
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
> ---
> drivers/infiniband/core/nldev.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
It was already fixed, https://patch.msgid.link/20260903082550.2257-1-lirongqing@baidu.com
Thanks
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-09-23 8:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-16 18:31 [PATCH] RDMA/nldev: Fix ib_device reference leak in nldev_dellink() Wentao Liang
2026-09-23 8:32 ` Leon Romanovsky
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®