]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
bnxt_en: Fix possible memory leak in bnxt_rdma_aux_device_init()
authorVikas Gupta <vikas.gupta@broadcom.com>
Fri, 5 Apr 2024 23:55:11 +0000 (16:55 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 Apr 2024 09:19:28 +0000 (11:19 +0200)
[ Upstream commit 7ac10c7d728d75bc9daaa8fade3c7a3273b9a9ff ]

If ulp = kzalloc() fails, the allocated edev will leak because it is
not properly assigned and the cleanup path will not be able to free it.
Fix it by assigning it properly immediately after allocation.

Fixes: 303432211324 ("bnxt_en: Remove runtime interrupt vector allocation")
Reviewed-by: Andy Gospodarek <andrew.gospodarek@broadcom.com>
Signed-off-by: Vikas Gupta <vikas.gupta@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c

index 6ba2b9398633307f992431ce1c852d2693396eb3..7188ea81401de2b4af8fa74ac031bafad3fa9916 100644 (file)
@@ -394,12 +394,13 @@ void bnxt_rdma_aux_device_init(struct bnxt *bp)
        if (!edev)
                goto aux_dev_uninit;
 
+       aux_priv->edev = edev;
+
        ulp = kzalloc(sizeof(*ulp), GFP_KERNEL);
        if (!ulp)
                goto aux_dev_uninit;
 
        edev->ulp_tbl = ulp;
-       aux_priv->edev = edev;
        bp->edev = edev;
        bnxt_set_edev_info(edev, bp);