diff options
author | Leon Romanovsky <leonro@mellanox.com> | 2018-06-24 11:23:47 +0300 |
---|---|---|
committer | Jason Gunthorpe <jgg@mellanox.com> | 2018-06-26 14:37:26 -0600 |
commit | a5cc9831af05e658543593abaee45a29d061bac4 (patch) | |
tree | eee06b73f3d4ef70e55d0df13ed6f95010349a9e /drivers/infiniband/core/uverbs_cmd.c | |
parent | 1ccddc42da03876f60fe2d0a1b124c27ed5ff201 (diff) | |
download | linux-a5cc9831af05e658543593abaee45a29d061bac4.tar.bz2 |
RDMA/uverbs: Don't overwrite NULL pointer with ZERO_SIZE_PTR
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>
Diffstat (limited to 'drivers/infiniband/core/uverbs_cmd.c')
-rw-r--r-- | drivers/infiniband/core/uverbs_cmd.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c index 74c5bc934822..7d70d17a853a 100644 --- a/drivers/infiniband/core/uverbs_cmd.c +++ b/drivers/infiniband/core/uverbs_cmd.c @@ -2763,6 +2763,9 @@ static struct ib_uflow_resources *flow_resources_alloc(size_t num_specs) if (!resources) return NULL; + if (!num_specs) + goto out; + resources->counters = kcalloc(num_specs, sizeof(*resources->counters), GFP_KERNEL); resources->collection = @@ -2771,8 +2774,8 @@ static struct ib_uflow_resources *flow_resources_alloc(size_t num_specs) if (!resources->counters || !resources->collection) goto err; +out: resources->max = num_specs; - return resources; err: |