diff mbox series

RDMA/nldev: Add checks for nla_nest_start() in fill_stat_counter_qps()

Message ID 20221126043410.85632-1-yuancan@huawei.com (mailing list archive)
State Accepted
Headers show
Series RDMA/nldev: Add checks for nla_nest_start() in fill_stat_counter_qps() | expand

Commit Message

Yuan Can Nov. 26, 2022, 4:34 a.m. UTC
As the nla_nest_start() may fail with NULL returned, the return value needs
to be checked.

Fixes: c4ffee7c9bdb ("RDMA/netlink: Implement counter dumpit calback")
Signed-off-by: Yuan Can <yuancan@huawei.com>
---
 drivers/infiniband/core/nldev.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Leon Romanovsky Nov. 28, 2022, 11:44 a.m. UTC | #1
On Sat, 26 Nov 2022 04:34:10 +0000, Yuan Can wrote:
> As the nla_nest_start() may fail with NULL returned, the return value needs
> to be checked.
> 
> 

Applied, thanks!

[1/1] RDMA/nldev: Add checks for nla_nest_start() in fill_stat_counter_qps()
      https://git.kernel.org/rdma/rdma/c/ea5ef136e215fd

Best regards,
diff mbox series

Patch

diff --git a/drivers/infiniband/core/nldev.c b/drivers/infiniband/core/nldev.c
index 12dc97067ed2..f3309f07e466 100644
--- a/drivers/infiniband/core/nldev.c
+++ b/drivers/infiniband/core/nldev.c
@@ -894,6 +894,8 @@  static int fill_stat_counter_qps(struct sk_buff *msg,
 	int ret = 0;
 
 	table_attr = nla_nest_start(msg, RDMA_NLDEV_ATTR_RES_QP);
+	if (!table_attr)
+		return -EMSGSIZE;
 
 	rt = &counter->device->res[RDMA_RESTRACK_QP];
 	xa_lock(&rt->xa);