Commit c5f42b21 authored by Gal Pressman's avatar Gal Pressman Committed by Jason Gunthorpe

RDMA/core: Check for error instead of success in alloc MR function

The common kernel pattern is to check for error, not success.  Flip the if
statement accordingly and keep the main flow unindented.

Link: https://lore.kernel.org/r/20200706120343.10816-2-galpress@amazon.comSigned-off-by: default avatarGal Pressman <galpress@amazon.com>
Reviewed-by: default avatarLeon Romanovsky <leonro@mellanox.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
parent c367124e
...@@ -2133,18 +2133,19 @@ struct ib_mr *ib_alloc_mr_user(struct ib_pd *pd, enum ib_mr_type mr_type, ...@@ -2133,18 +2133,19 @@ struct ib_mr *ib_alloc_mr_user(struct ib_pd *pd, enum ib_mr_type mr_type,
} }
mr = pd->device->ops.alloc_mr(pd, mr_type, max_num_sg, udata); mr = pd->device->ops.alloc_mr(pd, mr_type, max_num_sg, udata);
if (!IS_ERR(mr)) { if (IS_ERR(mr))
mr->device = pd->device; goto out;
mr->pd = pd;
mr->dm = NULL; mr->device = pd->device;
mr->uobject = NULL; mr->pd = pd;
atomic_inc(&pd->usecnt); mr->dm = NULL;
mr->need_inval = false; mr->uobject = NULL;
mr->res.type = RDMA_RESTRACK_MR; atomic_inc(&pd->usecnt);
rdma_restrack_kadd(&mr->res); mr->need_inval = false;
mr->type = mr_type; mr->res.type = RDMA_RESTRACK_MR;
mr->sig_attrs = NULL; rdma_restrack_kadd(&mr->res);
} mr->type = mr_type;
mr->sig_attrs = NULL;
out: out:
trace_mr_alloc(pd, mr_type, max_num_sg, mr); trace_mr_alloc(pd, mr_type, max_num_sg, mr);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment