From: Ben Hutchings <ben@decadent.org.uk>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: akpm@linux-foundation.org, Matthew Daley <mattjd@gmail.com>,
Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
Ian Campbell <ian.campbell@citrix.com>,
Jan Beulich <JBeulich@suse.com>,
"David S. Miller" <davem@davemloft.net>
Subject: [ 57/66] xen/netback: dont leak pages on failure in xen_netbk_tx_check_gop.
Date: Sun, 17 Feb 2013 22:50:58 +0000 [thread overview]
Message-ID: <20130217225008.255403499@decadent.org.uk> (raw)
In-Reply-To: <20130217225001.621306883@decadent.org.uk>
3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthew Daley <mattjd@gmail.com>
[ Upstream commit 7d5145d8eb2b9791533ffe4dc003b129b9696c48 ]
Signed-off-by: Matthew Daley <mattjd@gmail.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Jan Beulich <JBeulich@suse.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
drivers/net/xen-netback/netback.c | 38 +++++++++++++-------------------------
1 file changed, 13 insertions(+), 25 deletions(-)
diff --git a/drivers/net/xen-netback/netback.c b/drivers/net/xen-netback/netback.c
index 6501813..d6c2359 100644
--- a/drivers/net/xen-netback/netback.c
+++ b/drivers/net/xen-netback/netback.c
@@ -146,7 +146,8 @@ void xen_netbk_remove_xenvif(struct xenvif *vif)
atomic_dec(&netbk->netfront_count);
}
-static void xen_netbk_idx_release(struct xen_netbk *netbk, u16 pending_idx);
+static void xen_netbk_idx_release(struct xen_netbk *netbk, u16 pending_idx,
+ u8 status);
static void make_tx_response(struct xenvif *vif,
struct xen_netif_tx_request *txp,
s8 st);
@@ -981,30 +982,20 @@ static int xen_netbk_tx_check_gop(struct xen_netbk *netbk,
{
struct gnttab_copy *gop = *gopp;
u16 pending_idx = *((u16 *)skb->data);
- struct pending_tx_info *pending_tx_info = netbk->pending_tx_info;
- struct xenvif *vif = pending_tx_info[pending_idx].vif;
- struct xen_netif_tx_request *txp;
struct skb_shared_info *shinfo = skb_shinfo(skb);
int nr_frags = shinfo->nr_frags;
int i, err, start;
/* Check status of header. */
err = gop->status;
- if (unlikely(err)) {
- pending_ring_idx_t index;
- index = pending_index(netbk->pending_prod++);
- txp = &pending_tx_info[pending_idx].req;
- make_tx_response(vif, txp, XEN_NETIF_RSP_ERROR);
- netbk->pending_ring[index] = pending_idx;
- xenvif_put(vif);
- }
+ if (unlikely(err))
+ xen_netbk_idx_release(netbk, pending_idx, XEN_NETIF_RSP_ERROR);
/* Skip first skb fragment if it is on same page as header fragment. */
start = (frag_get_pending_idx(&shinfo->frags[0]) == pending_idx);
for (i = start; i < nr_frags; i++) {
int j, newerr;
- pending_ring_idx_t index;
pending_idx = frag_get_pending_idx(&shinfo->frags[i]);
@@ -1013,16 +1004,12 @@ static int xen_netbk_tx_check_gop(struct xen_netbk *netbk,
if (likely(!newerr)) {
/* Had a previous error? Invalidate this fragment. */
if (unlikely(err))
- xen_netbk_idx_release(netbk, pending_idx);
+ xen_netbk_idx_release(netbk, pending_idx, XEN_NETIF_RSP_OKAY);
continue;
}
/* Error on this fragment: respond to client with an error. */
- txp = &netbk->pending_tx_info[pending_idx].req;
- make_tx_response(vif, txp, XEN_NETIF_RSP_ERROR);
- index = pending_index(netbk->pending_prod++);
- netbk->pending_ring[index] = pending_idx;
- xenvif_put(vif);
+ xen_netbk_idx_release(netbk, pending_idx, XEN_NETIF_RSP_ERROR);
/* Not the first error? Preceding frags already invalidated. */
if (err)
@@ -1030,10 +1017,10 @@ static int xen_netbk_tx_check_gop(struct xen_netbk *netbk,
/* First error: invalidate header and preceding fragments. */
pending_idx = *((u16 *)skb->data);
- xen_netbk_idx_release(netbk, pending_idx);
+ xen_netbk_idx_release(netbk, pending_idx, XEN_NETIF_RSP_OKAY);
for (j = start; j < i; j++) {
pending_idx = frag_get_pending_idx(&shinfo->frags[j]);
- xen_netbk_idx_release(netbk, pending_idx);
+ xen_netbk_idx_release(netbk, pending_idx, XEN_NETIF_RSP_OKAY);
}
/* Remember the error: invalidate all subsequent fragments. */
@@ -1067,7 +1054,7 @@ static void xen_netbk_fill_frags(struct xen_netbk *netbk, struct sk_buff *skb)
/* Take an extra reference to offset xen_netbk_idx_release */
get_page(netbk->mmap_pages[pending_idx]);
- xen_netbk_idx_release(netbk, pending_idx);
+ xen_netbk_idx_release(netbk, pending_idx, XEN_NETIF_RSP_OKAY);
}
}
@@ -1452,7 +1439,7 @@ static void xen_netbk_tx_submit(struct xen_netbk *netbk)
txp->size -= data_len;
} else {
/* Schedule a response immediately. */
- xen_netbk_idx_release(netbk, pending_idx);
+ xen_netbk_idx_release(netbk, pending_idx, XEN_NETIF_RSP_OKAY);
}
if (txp->flags & XEN_NETTXF_csum_blank)
@@ -1507,7 +1494,8 @@ static void xen_netbk_tx_action(struct xen_netbk *netbk)
}
-static void xen_netbk_idx_release(struct xen_netbk *netbk, u16 pending_idx)
+static void xen_netbk_idx_release(struct xen_netbk *netbk, u16 pending_idx,
+ u8 status)
{
struct xenvif *vif;
struct pending_tx_info *pending_tx_info;
@@ -1521,7 +1509,7 @@ static void xen_netbk_idx_release(struct xen_netbk *netbk, u16 pending_idx)
vif = pending_tx_info->vif;
- make_tx_response(vif, &pending_tx_info->req, XEN_NETIF_RSP_OKAY);
+ make_tx_response(vif, &pending_tx_info->req, status);
index = pending_index(netbk->pending_prod++);
netbk->pending_ring[index] = pending_idx;
next prev parent reply other threads:[~2013-02-17 22:50 UTC|newest]
Thread overview: 70+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-17 22:50 [ 00/66] 3.2.39-stable review Ben Hutchings
2013-02-17 22:50 ` [ 01/66] drm/i915: Fix misplaced intel_mark_page_flip_active() Ben Hutchings
2013-02-17 22:50 ` [ 02/66] xhci: Fix isoc TD encoding Ben Hutchings
2013-02-17 22:50 ` [ 03/66] xhci: Fix TD size for isochronous URBs Ben Hutchings
2013-02-17 22:50 ` [ 04/66] USB: XHCI: fix memory leak of URB-private data Ben Hutchings
2013-02-17 22:50 ` [ 05/66] usb: Prevent dead ports when xhci is not enabled Ben Hutchings
2013-02-17 22:50 ` [ 06/66] sched/rt: Use root_domain of rt_rq not current processor Ben Hutchings
2013-02-17 22:50 ` [ 07/66] rtlwifi: Fix the usage of the wrong variable in usb.c Ben Hutchings
2013-02-17 22:50 ` [ 08/66] drm/radeon: add quirk for RV100 board Ben Hutchings
2013-02-17 22:50 ` [ 09/66] USB: qcserial: add Telit Gobi QDL device Ben Hutchings
2013-02-17 22:50 ` [ 10/66] USB: option: add support for Telit LE920 Ben Hutchings
2013-02-17 22:50 ` [ 11/66] mwifiex: fix incomplete scan in case of IE parsing error Ben Hutchings
2013-02-17 22:50 ` [ 12/66] USB: EHCI: fix bug in scheduling periodic split transfers Ben Hutchings
2013-02-17 22:50 ` [ 13/66] x86-64: Replace left over sti/cli in ia32 audit exit code Ben Hutchings
2013-02-17 22:50 ` [ 14/66] Bluetooth: Fix handling of unexpected SMP PDUs Ben Hutchings
2013-02-17 22:50 ` [ 15/66] drm/radeon: Calling object_unrefer() when creating fb failure Ben Hutchings
2013-02-17 22:50 ` [ 16/66] drm/radeon: prevent crash in the ring space allocation Ben Hutchings
2013-02-17 22:50 ` [ 17/66] can: c_can: Set reserved bit in IFx_MASK2 to 1 on write Ben Hutchings
2013-02-17 22:50 ` [ 18/66] USB: ftdi_sio: add PID/VID entries for ELV WS 300 PC II Ben Hutchings
2013-02-17 22:50 ` [ 19/66] USB: option: add Changhong CH690 Ben Hutchings
2013-02-17 22:50 ` [ 20/66] USB: ftdi_sio: add Zolix FTDI PID Ben Hutchings
2013-02-17 22:50 ` [ 21/66] USB: storage: Define a new macro for USB storage match rules Ben Hutchings
2013-02-17 22:50 ` [ 22/66] USB: storage: optimize to match the Huawei USB storage devices and support new switch command Ben Hutchings
2013-02-17 22:50 ` [ 23/66] nilfs2: fix fix very long mount time issue Ben Hutchings
2013-02-17 22:50 ` [ 24/66] drivers/rtc/rtc-isl1208.c: call rtc_update_irq() from the alarm irq handler Ben Hutchings
2013-02-17 22:50 ` [ 25/66] drivers/rtc/rtc-pl031.c: fix the missing operation on enable Ben Hutchings
2013-02-17 22:50 ` [ 26/66] virtio_console: Dont access uninitialized data Ben Hutchings
2013-02-17 22:50 ` [ 27/66] wireless: rt2x00: rt{2500,73}usb.c put back duplicate id Ben Hutchings
2013-02-17 22:50 ` [ 28/66] Wireless: rt2x00: Add device id for Sweex LW323 to rt2800usb.c Ben Hutchings
2013-02-17 22:50 ` [ 29/66] rt2800usb: Add support for 2001:3c1e (D-Link DWA-125 rev B1) USB Wi-Fi adapter Ben Hutchings
2013-02-17 22:50 ` [ 30/66] [media] gspca_kinect: add Kinect for Windows USB id Ben Hutchings
2013-02-17 22:50 ` [ 31/66] ahci: support the STA2X11 I/O Hub Ben Hutchings
2013-02-17 22:50 ` [ 32/66] [libata] ahci: Add support for Enmotus Bobcat device Ben Hutchings
2013-02-17 22:50 ` [ 33/66] ptrace/x86: Introduce set_task_blockstep() helper Ben Hutchings
2013-02-17 22:50 ` [ 34/66] ptrace/x86: Partly fix set_task_blockstep()->update_debugctlmsr() logic Ben Hutchings
2013-02-17 22:50 ` [ 35/66] ptrace: introduce signal_wake_up_state() and ptrace_signal_wake_up() Ben Hutchings
2013-02-17 22:50 ` [ 36/66] ptrace: ensure arch_ptrace/ptrace_request can never race with SIGKILL Ben Hutchings
2013-02-17 22:50 ` [ 37/66] wake_up_process() should be never used to wakeup a TASK_STOPPED/TRACED task Ben Hutchings
2013-02-17 22:50 ` [ 38/66] Bluetooth: Fix sending HCI commands after reset Ben Hutchings
2013-02-17 22:50 ` [ 39/66] HID: usbhid: quirk for Formosa IR receiver Ben Hutchings
2013-02-17 22:50 ` [ 40/66] kernel/resource.c: fix stack overflow in __reserve_region_with_split() Ben Hutchings
2013-02-17 22:50 ` [ 41/66] net: prevent setting ttl=0 via IP_TTL Ben Hutchings
2013-02-17 22:50 ` [ 42/66] ipv6: fix the noflags test in addrconf_get_prefix_route Ben Hutchings
2013-02-17 22:50 ` [ 43/66] MAINTAINERS: Stephen Hemminger email change Ben Hutchings
2013-02-17 22:50 ` [ 44/66] ipv6: fix header length calculation in ip6_append_data() Ben Hutchings
2013-02-17 22:50 ` [ 45/66] isdn/gigaset: fix zero size border case in debug dump Ben Hutchings
2013-02-17 22:50 ` [ 46/66] netxen: fix off by one bug in netxen_release_tx_buffer() Ben Hutchings
2013-02-17 22:50 ` [ 47/66] r8169: remove the obsolete and incorrect AMD workaround Ben Hutchings
2013-02-17 22:50 ` [ 48/66] net: loopback: fix a dst refcounting issue Ben Hutchings
2013-02-17 22:50 ` [ 49/66] pktgen: correctly handle failures when adding a device Ben Hutchings
2013-02-17 22:50 ` [ 50/66] ipv6: do not create neighbor entries for local delivery Ben Hutchings
2013-02-17 22:50 ` [ 51/66] packet: fix leakage of tx_ring memory Ben Hutchings
2013-02-17 22:50 ` [ 52/66] atm/iphase: rename fregt_t -> ffreg_t Ben Hutchings
2013-02-17 22:50 ` [ 53/66] sctp: refactor sctp_outq_teardown to insure proper re-initalization Ben Hutchings
2013-02-17 22:50 ` [ 54/66] net: sctp: sctp_setsockopt_auth_key: use kzfree instead of kfree Ben Hutchings
2013-02-17 22:50 ` [ 55/66] net: sctp: sctp_endpoint_free: zero out secret key data Ben Hutchings
2013-02-17 22:50 ` [ 56/66] xen/netback: shutdown the ring if it contains garbage Ben Hutchings
2013-02-17 22:50 ` Ben Hutchings [this message]
2013-02-17 22:50 ` [ 58/66] xen/netback: free already allocated memory on failure in xen_netbk_get_requests Ben Hutchings
2013-02-17 22:51 ` [ 59/66] netback: correct netbk_tx_err to handle wrap around Ben Hutchings
2013-02-17 22:51 ` [ 60/66] tcp: frto should not set snd_cwnd to 0 Ben Hutchings
2013-02-17 22:51 ` [ 61/66] tcp: fix for zero packets_in_flight was too broad Ben Hutchings
2013-02-17 22:51 ` [ 62/66] tcp: fix MSG_SENDPAGE_NOTLAST logic Ben Hutchings
2013-02-17 22:51 ` [ 63/66] bridge: Pull ip header into skb->data before looking into ip header Ben Hutchings
2013-02-17 22:51 ` [ 64/66] tg3: Avoid null pointer dereference in tg3_interrupt in netconsole mode Ben Hutchings
2013-02-17 22:51 ` [ 65/66] tg3: Fix crc errors on jumbo frame receive Ben Hutchings
2013-02-17 22:51 ` [ 66/66] x86/xen: dont assume %ds is usable in xen_iret for 32-bit PVOPS Ben Hutchings
2013-02-18 0:02 ` [ 00/66] 3.2.39-stable review Ben Hutchings
2013-02-19 22:25 ` Satoru Takeuchi
2013-02-20 2:59 ` Ben Hutchings
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=20130217225008.255403499@decadent.org.uk \
--to=ben@decadent.org.uk \
--cc=JBeulich@suse.com \
--cc=akpm@linux-foundation.org \
--cc=davem@davemloft.net \
--cc=ian.campbell@citrix.com \
--cc=konrad.wilk@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mattjd@gmail.com \
--cc=stable@vger.kernel.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).