Commit 9bb2b31e authored by Divy Le Ray's avatar Divy Le Ray Committed by David S. Miller

cxgb3: release page ref on mapping error

Release page chunk reference in case we fail to map it.
Signed-off-by: default avatarDivy Le Ray <divy@chelsio.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 26b3871d
...@@ -338,6 +338,18 @@ static inline int should_restart_tx(const struct sge_txq *q) ...@@ -338,6 +338,18 @@ static inline int should_restart_tx(const struct sge_txq *q)
return q->in_use - r < (q->size >> 1); 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 * free_rx_bufs - free the Rx buffers on an SGE free list
* @pdev: the PCI device associated with the adapter * @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) ...@@ -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), pci_unmap_single(pdev, pci_unmap_addr(d, dma_addr),
q->buf_size, PCI_DMA_FROMDEVICE); q->buf_size, PCI_DMA_FROMDEVICE);
if (q->use_pages) { clear_rx_desc(q, d);
if (d->pg_chunk.page)
put_page(d->pg_chunk.page);
d->pg_chunk.page = NULL;
} else {
kfree_skb(d->skb);
d->skb = NULL;
}
if (++cidx == q->size) if (++cidx == q->size)
cidx = 0; cidx = 0;
} }
...@@ -475,10 +480,7 @@ nomem: q->alloc_failed++; ...@@ -475,10 +480,7 @@ nomem: q->alloc_failed++;
err = add_one_rx_buf(buf_start, q->buf_size, d, sd, q->gen, err = add_one_rx_buf(buf_start, q->buf_size, d, sd, q->gen,
adap->pdev); adap->pdev);
if (unlikely(err)) { if (unlikely(err)) {
if (!q->use_pages) { clear_rx_desc(q, sd);
kfree_skb(sd->skb);
sd->skb = NULL;
}
break; break;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment