]> www.infradead.org Git - users/hch/configfs.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)
committerDavid S. Miller <davem@davemloft.net>
Mon, 8 Apr 2024 12:55:46 +0000 (13:55 +0100)
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>
drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c

index 93f9bd55020f277f02fb6ed959bd5e82ec35fd93..a5f9c9090a6b0d04993c8d55962bce0250ced4e4 100644 (file)
@@ -392,12 +392,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);