qlge: Fixed double pci free upon tx_ring->q allocation failure.
authorJitendra Kalsaria <jitendra.kalsaria@qlogic.com>
Tue, 10 Jul 2012 14:57:36 +0000 (14:57 +0000)
committerDavid S. Miller <davem@davemloft.net>
Wed, 11 Jul 2012 06:28:33 +0000 (23:28 -0700)
Signed-off-by: Jitendra Kalsaria <jitendra.kalsaria@qlogic.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/qlogic/qlge/qlge_main.c

index 5cfba6aa1b9233f2e8012b3654cdd61e8cf3f538..bccbc4e2b31a736b60a7f948e258b3ae1e48c0ec 100644 (file)
@@ -2708,10 +2708,9 @@ static int ql_alloc_tx_resources(struct ql_adapter *qdev,
                                 &tx_ring->wq_base_dma);
 
        if ((tx_ring->wq_base == NULL) ||
-           tx_ring->wq_base_dma & WQ_ADDR_ALIGN) {
-               netif_err(qdev, ifup, qdev->ndev, "tx_ring alloc failed.\n");
-               return -ENOMEM;
-       }
+           tx_ring->wq_base_dma & WQ_ADDR_ALIGN)
+               goto pci_alloc_err;
+
        tx_ring->q =
            kmalloc(tx_ring->wq_len * sizeof(struct tx_ring_desc), GFP_KERNEL);
        if (tx_ring->q == NULL)
@@ -2721,6 +2720,9 @@ static int ql_alloc_tx_resources(struct ql_adapter *qdev,
 err:
        pci_free_consistent(qdev->pdev, tx_ring->wq_size,
                            tx_ring->wq_base, tx_ring->wq_base_dma);
+       tx_ring->wq_base = NULL;
+pci_alloc_err:
+       netif_err(qdev, ifup, qdev->ndev, "tx_ring alloc failed.\n");
        return -ENOMEM;
 }