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 3/4] xen/netback: free already allocated memory on failure in xen_netbk_get_requests
Date: Wed, 6 Feb 2013 17:18:17 +0000 [thread overview]
Message-ID: <1360171098-1240-3-git-send-email-ian.campbell@citrix.com> (raw)
In-Reply-To: <1360171081.32479.20.camel@zakaz.uk.xensource.com>
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
---
drivers/net/xen-netback/netback.c | 16 +++++++++++++++-
1 files changed, 15 insertions(+), 1 deletions(-)
diff --git a/drivers/net/xen-netback/netback.c b/drivers/net/xen-netback/netback.c
index 975241e..1a99288 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,20 @@ static struct gnttab_copy *xen_netbk_get_requests(struct xen_netbk *netbk,
}
return gop;
+err:
+ /*
+ * Unwind, freeing all pages and sending error
+ * reponses.
+ */
+ 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
next prev parent reply other threads:[~2013-02-06 17:18 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-06 17:18 [PATCH 0/4] XSA-39 CVE-2013-021[67]: Linux netback DoS via malicious guest ring Ian Campbell
2013-02-06 17:18 ` [PATCH 1/4] xen/netback: shutdown the ring if it contains garbage Ian Campbell
2013-02-06 17:18 ` [PATCH 2/4] xen/netback: don't leak pages on failure in xen_netbk_tx_check_gop Ian Campbell
2013-02-06 17:18 ` Ian Campbell [this message]
2013-02-06 17:31 ` [PATCH 3/4] xen/netback: free already allocated memory on failure in xen_netbk_get_requests Ben Pfaff
2013-02-06 18:47 ` David Miller
2013-02-07 9:40 ` Ian Campbell
2013-02-06 17:18 ` [PATCH 4/4] netback: correct netbk_tx_err to handle wrap around 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=1360171098-1240-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