[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20260126074801.627898-1-zilin@seu.edu.cn>
Date: Mon, 26 Jan 2026 07:48:01 +0000
From: Zilin Guan <zilin@....edu.cn>
To: leon@...nel.org
Cc: jgg@...pe.ca,
yishaih@...dia.com,
linux-rdma@...r.kernel.org,
linux-kernel@...r.kernel.org,
jianhao.xu@....edu.cn,
Zilin Guan <zilin@....edu.cn>
Subject: [PATCH] RDMA/mlx5: Fix memory leak in GET_DATA_DIRECT_SYSFS_PATH handler
The UVERBS_HANDLER(MLX5_IB_METHOD_GET_DATA_DIRECT_SYSFS_PATH) function
allocates memory for the device path using kobject_get_path(). If the
length of the device path exceeds the output buffer length, the function
returns -ENOSPC but does not free the allocated memory, resulting in a
memory leak.
Add a kfree() call to the error path to ensure the allocated memory is
properly freed.
Compile tested only. Issue found using a prototype static analysis tool
and code review.
Fixes: ec7ad6530909 ("RDMA/mlx5: Introduce GET_DATA_DIRECT_SYSFS_PATH ioctl")
Signed-off-by: Zilin Guan <zilin@....edu.cn>
---
drivers/infiniband/hw/mlx5/std_types.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/infiniband/hw/mlx5/std_types.c b/drivers/infiniband/hw/mlx5/std_types.c
index 2fcf553044e1..ed4f5abb63c8 100644
--- a/drivers/infiniband/hw/mlx5/std_types.c
+++ b/drivers/infiniband/hw/mlx5/std_types.c
@@ -218,6 +218,7 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_GET_DATA_DIRECT_SYSFS_PATH)(
dev_path_len = strlen(dev_path) + 1;
if (dev_path_len > out_len) {
ret = -ENOSPC;
+ kfree(dev_path);
goto end;
}
--
2.34.1
Powered by blists - more mailing lists