summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Campbell <Ian.Campbell@citrix.com>2013-02-06 23:41:37 +0000
committerBen Hutchings <ben@decadent.org.uk>2013-02-20 03:15:37 +0000
commit79d2fa0811ed0dadeb745daa0067eb672ec12fb7 (patch)
tree6e90c15cc4c2ca36bbfd577b7d221459ec8e98e2
parentdd4d2748d11f601975b78c88130bd274d3e90eb5 (diff)
downloadlwn-79d2fa0811ed0dadeb745daa0067eb672ec12fb7.tar.gz
lwn-79d2fa0811ed0dadeb745daa0067eb672ec12fb7.zip
xen/netback: free already allocated memory on failure in xen_netbk_get_requests
[ Upstream commit 4cc7c1cb7b11b6f3515bd9075527576a1eecc4aa ] Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
-rw-r--r--drivers/net/xen-netback/netback.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/drivers/net/xen-netback/netback.c b/drivers/net/xen-netback/netback.c
index d6c235990374..a14b3a2a2f1d 100644
--- a/drivers/net/xen-netback/netback.c
+++ b/drivers/net/xen-netback/netback.c
@@ -950,7 +950,7 @@ static struct gnttab_copy *xen_netbk_get_requests(struct xen_netbk *netbk,
pending_idx = netbk->pending_ring[index];
page = xen_netbk_alloc_page(netbk, skb, pending_idx);
if (!page)
- return NULL;
+ goto err;
netbk->mmap_pages[pending_idx] = page;
@@ -974,6 +974,17 @@ static struct gnttab_copy *xen_netbk_get_requests(struct xen_netbk *netbk,
}
return gop;
+err:
+ /* Unwind, freeing all pages and sending error responses. */
+ while (i-- > start) {
+ xen_netbk_idx_release(netbk, frag_get_pending_idx(&frags[i]),
+ XEN_NETIF_RSP_ERROR);
+ }
+ /* The head too, if necessary. */
+ if (start)
+ xen_netbk_idx_release(netbk, pending_idx, XEN_NETIF_RSP_ERROR);
+
+ return NULL;
}
static int xen_netbk_tx_check_gop(struct xen_netbk *netbk,