netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ian Campbell <ian.campbell@citrix.com>
To: <netdev@vger.kernel.org>
Cc: <xen-devel@lists.xen.org>, Ian Campbell <ian.campbell@citrix.com>
Subject: [PATCH v2 3/4] xen/netback: free already allocated memory on failure in xen_netbk_get_requests
Date: Thu, 7 Feb 2013 09:41:37 +0000	[thread overview]
Message-ID: <1360230098-28218-3-git-send-email-ian.campbell@citrix.com> (raw)
In-Reply-To: <1360230078.32479.41.camel@zakaz.uk.xensource.com>

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Cc: <stable@vger.kernel.org> # 3.0+
---
v2: s/reponses/responses/ (blp) & fixup block comment style (DaveM)
---
 drivers/net/xen-netback/netback.c |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/drivers/net/xen-netback/netback.c b/drivers/net/xen-netback/netback.c
index bf692df..dcb2d4d 100644
--- a/drivers/net/xen-netback/netback.c
+++ b/drivers/net/xen-netback/netback.c
@@ -978,7 +978,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;
 
 		gop->source.u.ref = txp->gref;
 		gop->source.domid = vif->domid;
@@ -1000,6 +1000,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,
-- 
1.7.2.5

  parent reply	other threads:[~2013-02-07  9:41 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-07  9:41 [PATCH v2 0/4] XSA-39 CVE-2013-021[67]: Linux netback DoS via malicious guest ring Ian Campbell
2013-02-07  9:41 ` [PATCH v2 1/4] xen/netback: shutdown the ring if it contains garbage Ian Campbell
2013-02-07  9:41 ` [PATCH v2 2/4] xen/netback: don't leak pages on failure in xen_netbk_tx_check_gop Ian Campbell
2013-02-07  9:41 ` Ian Campbell [this message]
2013-02-07  9:41 ` [PATCH v2 4/4] netback: correct netbk_tx_err to handle wrap around Ian Campbell
2013-02-08  4:31 ` [PATCH v2 0/4] XSA-39 CVE-2013-021[67]: Linux netback DoS via malicious guest ring David Miller
2013-02-08  7:54   ` Ian Campbell

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=1360230098-28218-3-git-send-email-ian.campbell@citrix.com \
    --to=ian.campbell@citrix.com \
    --cc=netdev@vger.kernel.org \
    --cc=xen-devel@lists.xen.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;
as well as URLs for NNTP newsgroup(s).