summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeon Romanovsky <leonro@mellanox.com>2018-06-24 11:23:47 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-10-03 16:59:13 -0700
commit53b56e401d930d9d0ae148975c5c34f46df27b11 (patch)
treeb25d97fd0b81ca99fec7cf9d76f4efa096e64044
parent1da59841eea9bd521e1b42cb7b7eece12247019e (diff)
downloadlinux-stable-53b56e401d930d9d0ae148975c5c34f46df27b11.tar.gz
linux-stable-53b56e401d930d9d0ae148975c5c34f46df27b11.tar.bz2
linux-stable-53b56e401d930d9d0ae148975c5c34f46df27b11.zip
RDMA/uverbs: Don't overwrite NULL pointer with ZERO_SIZE_PTR
[ Upstream commit a5cc9831af05e658543593abaee45a29d061bac4 ] Number of specs is provided by user and in valid case can be equal to zero. Such argument causes to call to kcalloc() with zero-length request and in return the ZERO_SIZE_PTR is assigned. This pointer is different from NULL and makes various if (..) checks to success. Fixes: b6ba4a9aa59f ("IB/uverbs: Add support for flow counters") Signed-off-by: Leon Romanovsky <leonro@mellanox.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com> Signed-off-by: Sasha Levin <alexander.levin@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/infiniband/core/uverbs_cmd.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
index 583d3a10b940..0e5eb0f547d3 100644
--- a/drivers/infiniband/core/uverbs_cmd.c
+++ b/drivers/infiniband/core/uverbs_cmd.c
@@ -2812,6 +2812,9 @@ static struct ib_uflow_resources *flow_resources_alloc(size_t num_specs)
if (!resources)
goto err_res;
+ if (!num_specs)
+ goto out;
+
resources->counters =
kcalloc(num_specs, sizeof(*resources->counters), GFP_KERNEL);
@@ -2824,8 +2827,8 @@ static struct ib_uflow_resources *flow_resources_alloc(size_t num_specs)
if (!resources->collection)
goto err_collection;
+out:
resources->max = num_specs;
-
return resources;
err_collection: