diff mbox

[3/4] xen/netback: free already allocated memory on failure in xen_netbk_get_requests

Message ID 1360171098-1240-3-git-send-email-ian.campbell@citrix.com
State Changes Requested, archived
Delegated to: David Miller
Headers show

Commit Message

Ian Campbell Feb. 6, 2013, 5:18 p.m. UTC
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
---
 drivers/net/xen-netback/netback.c |   16 +++++++++++++++-
 1 files changed, 15 insertions(+), 1 deletions(-)

Comments

Ben Pfaff Feb. 6, 2013, 5:31 p.m. UTC | #1
Ian Campbell <ian.campbell@citrix.com> writes:

> +	/*
> +	 * Unwind, freeing all pages and sending error
> +	 * reponses.
> +	 */

s/reponses/responses/
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller Feb. 6, 2013, 6:47 p.m. UTC | #2
From: Ben Pfaff <blp@cs.stanford.edu>
Date: Wed, 06 Feb 2013 09:31:24 -0800

> Ian Campbell <ian.campbell@citrix.com> writes:
> 
>> +	/*
>> +	 * Unwind, freeing all pages and sending error
>> +	 * reponses.
>> +	 */
> 
> s/reponses/responses/

Also please format your comments in the standard networking form
which is:

	/* Like
	 * this.
	 */

Patch #1 has the same problem, thanks Ian.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Ian Campbell Feb. 7, 2013, 9:40 a.m. UTC | #3
On Wed, 2013-02-06 at 18:47 +0000, David Miller wrote:
> From: Ben Pfaff <blp@cs.stanford.edu>
> Date: Wed, 06 Feb 2013 09:31:24 -0800
> 
> > Ian Campbell <ian.campbell@citrix.com> writes:
> > 
> >> +	/*
> >> +	 * Unwind, freeing all pages and sending error
> >> +	 * reponses.
> >> +	 */
> > 
> > s/reponses/responses/

Fixed, thanks!

> Also please format your comments in the standard networking form
> which is:
> 
> 	/* Like
> 	 * this.
> 	 */
> 
> Patch #1 has the same problem, thanks Ian.

I fixed this up, actually this particular one fits on a single line just
fine.

I'll resend shortly with the addition of the stable cc which I forgot
last time.

Thanks,
Ian.

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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,