From: Francois Romieu <romieu@fr.zoreil.com>
To: Jitendra Kalsaria <jitendra.kalsaria@qlogic.com>
Cc: davem@davemloft.net, netdev@vger.kernel.org, Ron@linux-zupk.site,
Dept_NX_Linux_NIC_Driver@qlogic.com
Subject: Re: [PATCH net-next 4/6] qlge: Fixed double pci free upon tx_ring->q allocation failure.
Date: Fri, 29 Jun 2012 23:37:55 +0200 [thread overview]
Message-ID: <20120629213755.GC19152@electric-eye.fr.zoreil.com> (raw)
In-Reply-To: <1340994290-28832-5-git-send-email-jitendra.kalsaria@qlogic.com>
Jitendra Kalsaria <jitendra.kalsaria@qlogic.com> :
[...]
> diff --git a/drivers/net/ethernet/qlogic/qlge/qlge_main.c b/drivers/net/ethernet/qlogic/qlge/qlge_main.c
> index cdbc860..aa514c5 100644
> --- a/drivers/net/ethernet/qlogic/qlge/qlge_main.c
> +++ b/drivers/net/ethernet/qlogic/qlge/qlge_main.c
> @@ -2701,11 +2701,9 @@ static int ql_alloc_tx_resources(struct ql_adapter *qdev,
> pci_alloc_consistent(qdev->pdev, tx_ring->wq_size,
> &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;
> - }
> + if ((tx_ring->wq_base == NULL) || tx_ring->wq_base_dma & WQ_ADDR_ALIGN)
> + goto err;
> +
> tx_ring->q =
> kmalloc(tx_ring->wq_len * sizeof(struct tx_ring_desc), GFP_KERNEL);
> if (tx_ring->q == NULL)
> @@ -2713,8 +2711,12 @@ static int ql_alloc_tx_resources(struct ql_adapter *qdev,
>
> return 0;
> err:
> - pci_free_consistent(qdev->pdev, tx_ring->wq_size,
> + if (tx_ring->wq_base) {
> + pci_free_consistent(qdev->pdev, tx_ring->wq_size,
> tx_ring->wq_base, tx_ring->wq_base_dma);
> + tx_ring->wq_base = NULL;
> + }
You do not need a test: use a second label + goto.
Nit: You can replace 'if ((tx_ring->wq_base == NULL)' with
'if (!tx_ring->wq_base' and add a local variable for qdev->pdev.
You may consider replacing pci_alloc_consistent with dma_alloc_coherent
in a future patch.
--
Ueimor
next prev parent reply other threads:[~2012-06-29 21:48 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-29 18:24 [PATCH net-next 0/6] qlge: bug fix Jitendra Kalsaria
2012-06-29 18:24 ` [PATCH net-next 1/6] qlge: Fixed packet transmit errors due to potential driver errors Jitendra Kalsaria
2012-06-29 18:24 ` [PATCH net-next 2/6] qlge: Stand-up card should not report supporting wol Jitendra Kalsaria
2012-06-29 21:37 ` Francois Romieu
2012-06-29 22:40 ` Jitendra Kalsaria
2012-06-29 23:02 ` Francois Romieu
2012-06-29 18:24 ` [PATCH net-next 3/6] qlge: Garbage values shown in extra info during selftest Jitendra Kalsaria
2012-06-29 18:24 ` [PATCH net-next 4/6] qlge: Fixed double pci free upon tx_ring->q allocation failure Jitendra Kalsaria
2012-06-29 21:37 ` Francois Romieu [this message]
2012-06-29 22:48 ` Jitendra Kalsaria
2012-06-29 18:24 ` [PATCH net-next 5/6] qlge: Categorize receive frame errors from firmware Jitendra Kalsaria
2012-06-29 21:38 ` Francois Romieu
2012-06-29 18:24 ` [PATCH net-next 6/6] qlge: Bumped driver version to 1.00.00.31 Jitendra Kalsaria
2012-06-29 21:36 ` [PATCH net-next 0/6] qlge: bug fix Francois Romieu
2012-06-29 21:40 ` Francois Romieu
2012-06-29 22:05 ` Jitendra Kalsaria
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120629213755.GC19152@electric-eye.fr.zoreil.com \
--to=romieu@fr.zoreil.com \
--cc=Dept_NX_Linux_NIC_Driver@qlogic.com \
--cc=Ron@linux-zupk.site \
--cc=davem@davemloft.net \
--cc=jitendra.kalsaria@qlogic.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox