diff options
author | Dinghao Liu <dinghao.liu@zju.edu.cn> | 2020-12-26 15:42:48 +0800 |
---|---|---|
committer | Jason Gunthorpe <jgg@nvidia.com> | 2021-01-07 16:07:12 -0400 |
commit | a306aba9c8d869b1fdfc8ad9237f1ed718ea55e6 (patch) | |
tree | b9c7ca37323ef42d8a615271f3fab857833dcca9 /drivers/infiniband | |
parent | 3c638cdb8ecc0442552156e0fed8708dd2c7f35b (diff) | |
download | linux-a306aba9c8d869b1fdfc8ad9237f1ed718ea55e6.tar.gz linux-a306aba9c8d869b1fdfc8ad9237f1ed718ea55e6.tar.bz2 linux-a306aba9c8d869b1fdfc8ad9237f1ed718ea55e6.zip |
RDMA/usnic: Fix memleak in find_free_vf_and_create_qp_grp
If usnic_ib_qp_grp_create() fails at the first call, dev_list
will not be freed on error, which leads to memleak.
Fixes: e3cf00d0a87f ("IB/usnic: Add Cisco VIC low-level hardware driver")
Link: https://lore.kernel.org/r/20201226074248.2893-1-dinghao.liu@zju.edu.cn
Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Diffstat (limited to 'drivers/infiniband')
-rw-r--r-- | drivers/infiniband/hw/usnic/usnic_ib_verbs.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/infiniband/hw/usnic/usnic_ib_verbs.c b/drivers/infiniband/hw/usnic/usnic_ib_verbs.c index 38a37770c016..3705c6b8b223 100644 --- a/drivers/infiniband/hw/usnic/usnic_ib_verbs.c +++ b/drivers/infiniband/hw/usnic/usnic_ib_verbs.c @@ -214,6 +214,7 @@ find_free_vf_and_create_qp_grp(struct usnic_ib_dev *us_ibdev, } usnic_uiom_free_dev_list(dev_list); + dev_list = NULL; } /* Try to find resources on an unused vf */ @@ -239,6 +240,8 @@ find_free_vf_and_create_qp_grp(struct usnic_ib_dev *us_ibdev, qp_grp_check: if (IS_ERR_OR_NULL(qp_grp)) { usnic_err("Failed to allocate qp_grp\n"); + if (usnic_ib_share_vf) + usnic_uiom_free_dev_list(dev_list); return ERR_PTR(qp_grp ? PTR_ERR(qp_grp) : -ENOMEM); } return qp_grp; |