mirror of
https://github.com/torvalds/linux.git
synced 2026-06-10 07:32:29 +02:00
RDMA/uverbs: check for allocation failure in uapi_add_elm()
[ Upstream commitcac2a301c0] If the kzalloc() fails then we should return ERR_PTR(-ENOMEM). In the current code it's possible that the kzalloc() fails and the radix_tree_insert() inserts the NULL pointer successfully and we return the NULL "elm" pointer to the caller. That results in a NULL pointer dereference. Fixes:9ed3e5f447("IB/uverbs: Build the specs into a radix tree at runtime") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
6c350e974c
commit
ccd93cb455
|
|
@ -17,6 +17,8 @@ static void *uapi_add_elm(struct uverbs_api *uapi, u32 key, size_t alloc_size)
|
|||
return ERR_PTR(-EOVERFLOW);
|
||||
|
||||
elm = kzalloc(alloc_size, GFP_KERNEL);
|
||||
if (!elm)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
rc = radix_tree_insert(&uapi->radix, key, elm);
|
||||
if (rc) {
|
||||
kfree(elm);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user