OSDN Git Service

RDMA/uverbs: Refactor flow_resources_alloc() function
authorLeon Romanovsky <leonro@mellanox.com>
Tue, 5 Jun 2018 04:55:02 +0000 (07:55 +0300)
committerJason Gunthorpe <jgg@mellanox.com>
Mon, 18 Jun 2018 17:09:05 +0000 (11:09 -0600)
Simplify the flow_resources_alloc() function call by reducing
number of goto statements.

Reviewed-by: Michael J. Ruhl <michael.j.ruhl@intel.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
drivers/infiniband/core/uverbs_cmd.c

index 3e90b6a..72803f8 100644 (file)
@@ -2761,29 +2761,24 @@ static struct ib_uflow_resources *flow_resources_alloc(size_t num_specs)
        resources = kzalloc(sizeof(*resources), GFP_KERNEL);
 
        if (!resources)
-               goto err_res;
+               return NULL;
 
        resources->counters =
                kcalloc(num_specs, sizeof(*resources->counters), GFP_KERNEL);
-
-       if (!resources->counters)
-               goto err_cnt;
-
        resources->collection =
                kcalloc(num_specs, sizeof(*resources->collection), GFP_KERNEL);
 
-       if (!resources->collection)
-               goto err_collection;
+       if (!resources->counters || !resources->collection)
+               goto err;
 
        resources->max = num_specs;
 
        return resources;
 
-err_collection:
+err:
        kfree(resources->counters);
-err_cnt:
        kfree(resources);
-err_res:
+
        return NULL;
 }