[PATCH] RDMA/iwpm: fix kref bypass in iwpm_add_mapping() error path
From: Wentao Liang
Date: Mon Jun 08 2026 - 11:52:29 EST
iwpm_get_nlmsg_request() returns with kref_init() + kref_get()
(refcount=2). iwpm_add_mapping() calls iwpm_free_nlmsg_request()
directly on the error path instead of using kref_put(), bypassing
the kref mechanism and freeing the object with a non-zero refcount.
Replace the direct iwpm_free_nlmsg_request() call with
kref_put(&nlmsg_request->kref, iwpm_free_nlmsg_request).
Cc: stable@xxxxxxxxxxxxxxx
Fixes: 30dc5e63d6a5 ("RDMA/core: Add support for iWARP Port Mapper user space service")
Signed-off-by: Wentao Liang <vulab@xxxxxxxxxxx>
---
drivers/infiniband/core/iwpm_msg.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/infiniband/core/iwpm_msg.c b/drivers/infiniband/core/iwpm_msg.c
index 672b0c33a6de..854c974d6586 100644
--- a/drivers/infiniband/core/iwpm_msg.c
+++ b/drivers/infiniband/core/iwpm_msg.c
@@ -207,7 +207,7 @@ int iwpm_add_mapping(struct iwpm_sa_data *pm_msg, u8 nl_client)
add_mapping_error_nowarn:
dev_kfree_skb(skb);
if (nlmsg_request)
- iwpm_free_nlmsg_request(&nlmsg_request->kref);
+ kref_put(&nlmsg_request->kref, iwpm_free_nlmsg_request);
return ret;
}
--
2.34.1