Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a5cc9831 authored by Leon Romanovsky's avatar Leon Romanovsky Committed by Jason Gunthorpe
Browse files

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: b6ba4a9a ("IB/uverbs: Add support for flow counters")
Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent 1ccddc42
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -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: