]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
RDMA/bnxt_re: Fix a possible memory leak
authorKalesh AP <kalesh-anakkur.purayil@broadcom.com>
Thu, 19 Sep 2024 03:05:56 +0000 (20:05 -0700)
committerLeon Romanovsky <leon@kernel.org>
Tue, 8 Oct 2024 07:11:50 +0000 (10:11 +0300)
In bnxt_re_setup_chip_ctx() when bnxt_qplib_map_db_bar() fails
driver is not freeing the memory allocated for "rdev->chip_ctx".

Fixes: 0ac20faf5d83 ("RDMA/bnxt_re: Reorg the bar mapping")
Link: https://patch.msgid.link/r/1726715161-18941-2-git-send-email-selvin.xavier@broadcom.com
Signed-off-by: Selvin Xavier <selvin.xavier@broadcom.com>
Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
drivers/infiniband/hw/bnxt_re/main.c

index 777068de4bbc170de47d214d05112c14901805d2..686e405f22b42ca75ea8a3ef8c48375a08959585 100644 (file)
@@ -188,8 +188,11 @@ static int bnxt_re_setup_chip_ctx(struct bnxt_re_dev *rdev)
 
        bnxt_re_set_db_offset(rdev);
        rc = bnxt_qplib_map_db_bar(&rdev->qplib_res);
-       if (rc)
+       if (rc) {
+               kfree(rdev->chip_ctx);
+               rdev->chip_ctx = NULL;
                return rc;
+       }
 
        if (bnxt_qplib_determine_atomics(en_dev->pdev))
                ibdev_info(&rdev->ibdev,