]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
qlcnic: Fix a memory leak in error handling path
authorChristophe Jaillet <christophe.jaillet@wanadoo.fr>
Sun, 19 Feb 2017 09:35:05 +0000 (10:35 +0100)
committerDavid S. Miller <davem@davemloft.net>
Mon, 20 Feb 2017 15:33:38 +0000 (10:33 -0500)
If 'dma_alloc_coherent()' fails, we should release resources allocated so
far, just as done in all other cases in this function.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/qlogic/qlcnic/qlcnic_ctx.c

index daf05155b7329abdda58e63b1c19be9e06adc699..d344e9d438321873fa8e4dedf745a74aeeb3db52 100644 (file)
@@ -573,8 +573,10 @@ int qlcnic_alloc_hw_resources(struct qlcnic_adapter *adapter)
                ptr = (__le32 *)dma_alloc_coherent(&pdev->dev, sizeof(u32),
                                                   &tx_ring->hw_cons_phys_addr,
                                                   GFP_KERNEL);
-               if (ptr == NULL)
-                       return -ENOMEM;
+               if (ptr == NULL) {
+                       err = -ENOMEM;
+                       goto err_out_free;
+               }
 
                tx_ring->hw_consumer = ptr;
                /* cmd desc ring */