Skip to content

Commit 7694a7d

Browse files
JiangJiasjgunthorpe
authored andcommitted
RDMA/uverbs: Check for null return of kmalloc_array
Because of the possible failure of the allocation, data might be NULL pointer and will cause the dereference of the NULL pointer later. Therefore, it might be better to check it and return -ENOMEM. Fixes: 6884c6c ("RDMA/verbs: Store the write/write_ex uapi entry points in the uverbs_api") Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jiasheng Jiang <[email protected]> Reviewed-by: Leon Romanovsky <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 4163cb3 commit 7694a7d

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/infiniband/core/uverbs_uapi.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,9 @@ static int uapi_finalize(struct uverbs_api *uapi)
447447
uapi->num_write_ex = max_write_ex + 1;
448448
data = kmalloc_array(uapi->num_write + uapi->num_write_ex,
449449
sizeof(*uapi->write_methods), GFP_KERNEL);
450+
if (!data)
451+
return -ENOMEM;
452+
450453
for (i = 0; i != uapi->num_write + uapi->num_write_ex; i++)
451454
data[i] = &uapi->notsupp_method;
452455
uapi->write_methods = data;

0 commit comments

Comments
 (0)