summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorDivy Le Ray <divy@chelsio.com>2009-03-12 21:13:49 +0000
committerDavid S. Miller <davem@davemloft.net>2009-03-13 11:30:43 -0700
commit9bb2b31e6f87dba06b81429af91362a9127f5bf2 (patch)
tree606f43f14468b125b876d53e67d941eb3b6f16ca /drivers
parent26b3871d2c82b7c733a3b6d631a6e48c9ebf1c5a (diff)
downloadop-kernel-dev-9bb2b31e6f87dba06b81429af91362a9127f5bf2.zip
op-kernel-dev-9bb2b31e6f87dba06b81429af91362a9127f5bf2.tar.gz
cxgb3: release page ref on mapping error
Release page chunk reference in case we fail to map it. Signed-off-by: Divy Le Ray <divy@chelsio.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/cxgb3/sge.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/drivers/net/cxgb3/sge.c b/drivers/net/cxgb3/sge.c
index 882beaf..808b8af 100644
--- a/drivers/net/cxgb3/sge.c
+++ b/drivers/net/cxgb3/sge.c
@@ -338,6 +338,18 @@ static inline int should_restart_tx(const struct sge_txq *q)
return q->in_use - r < (q->size >> 1);
}
+static void clear_rx_desc(const struct sge_fl *q, struct rx_sw_desc *d)
+{
+ if (q->use_pages) {
+ if (d->pg_chunk.page)
+ put_page(d->pg_chunk.page);
+ d->pg_chunk.page = NULL;
+ } else {
+ kfree_skb(d->skb);
+ d->skb = NULL;
+ }
+}
+
/**
* free_rx_bufs - free the Rx buffers on an SGE free list
* @pdev: the PCI device associated with the adapter
@@ -355,14 +367,7 @@ static void free_rx_bufs(struct pci_dev *pdev, struct sge_fl *q)
pci_unmap_single(pdev, pci_unmap_addr(d, dma_addr),
q->buf_size, PCI_DMA_FROMDEVICE);
- if (q->use_pages) {
- if (d->pg_chunk.page)
- put_page(d->pg_chunk.page);
- d->pg_chunk.page = NULL;
- } else {
- kfree_skb(d->skb);
- d->skb = NULL;
- }
+ clear_rx_desc(q, d);
if (++cidx == q->size)
cidx = 0;
}
@@ -475,10 +480,7 @@ nomem: q->alloc_failed++;
err = add_one_rx_buf(buf_start, q->buf_size, d, sd, q->gen,
adap->pdev);
if (unlikely(err)) {
- if (!q->use_pages) {
- kfree_skb(sd->skb);
- sd->skb = NULL;
- }
+ clear_rx_desc(q, sd);
break;
}
OpenPOWER on IntegriCloud