All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jiri Slaby <jslaby@suse.cz>
To: stable@vger.kernel.org
Cc: Felipe Balbi <felipe.balbi@linux.intel.com>, Jiri Slaby <jslaby@suse.cz>
Subject: [patch added to 3.12-stable] usb: dwc3: gadget: increment request->actual once
Date: Thu, 22 Sep 2016 09:11:22 +0200	[thread overview]
Message-ID: <20160922071154.1297-10-jslaby@suse.cz> (raw)
In-Reply-To: <20160922071154.1297-1-jslaby@suse.cz>

From: Felipe Balbi <felipe.balbi@linux.intel.com>

This patch has been added to the 3.12 stable tree. If you have any
objections, please let us know.

===============

commit c7de573471832dff7d31f0c13b0f143d6f017799 upstream.

When using SG lists, we would end up setting
request->actual to:

	num_mapped_sgs * (request->length - count)

Let's fix that up by incrementing request->actual
only once.

Reported-by: Brian E Rogers <brian.e.rogers@intel.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/usb/dwc3/gadget.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 346140c55430..af03ea2c9c78 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -1799,14 +1799,6 @@ static int __dwc3_cleanup_done_trbs(struct dwc3 *dwc, struct dwc3_ep *dep,
 			s_pkt = 1;
 	}
 
-	/*
-	 * We assume here we will always receive the entire data block
-	 * which we should receive. Meaning, if we program RX to
-	 * receive 4K but we receive only 2K, we assume that's all we
-	 * should receive and we simply bounce the request back to the
-	 * gadget driver for further processing.
-	 */
-	req->request.actual += req->request.length - count;
 	if (s_pkt)
 		return 1;
 	if ((event->status & DEPEVT_STATUS_LST) &&
@@ -1826,6 +1818,7 @@ static int dwc3_cleanup_done_reqs(struct dwc3 *dwc, struct dwc3_ep *dep,
 	struct dwc3_trb		*trb;
 	unsigned int		slot;
 	unsigned int		i;
+	int			count = 0;
 	int			ret;
 
 	do {
@@ -1842,6 +1835,8 @@ static int dwc3_cleanup_done_reqs(struct dwc3 *dwc, struct dwc3_ep *dep,
 				slot++;
 			slot %= DWC3_TRB_NUM;
 			trb = &dep->trb_pool[slot];
+			count += trb->size & DWC3_TRB_SIZE_MASK;
+
 
 			ret = __dwc3_cleanup_done_trbs(dwc, dep, req, trb,
 					event, status);
@@ -1849,6 +1844,14 @@ static int dwc3_cleanup_done_reqs(struct dwc3 *dwc, struct dwc3_ep *dep,
 				break;
 		}while (++i < req->request.num_mapped_sgs);
 
+		/*
+		 * We assume here we will always receive the entire data block
+		 * which we should receive. Meaning, if we program RX to
+		 * receive 4K but we receive only 2K, we assume that's all we
+		 * should receive and we simply bounce the request back to the
+		 * gadget driver for further processing.
+		 */
+		req->request.actual += req->request.length - count;
 		dwc3_gadget_giveback(dep, req, status);
 
 		if (ret)
-- 
2.10.0


  parent reply	other threads:[~2016-09-22  7:12 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-22  7:11 [patch added to 3.12-stable] MIPS: KVM: Check for pfn noslot case Jiri Slaby
2016-09-22  7:11 ` [patch added to 3.12-stable] x86/mm: Disable preemption during CR3 read+write Jiri Slaby
2016-09-22  7:11   ` Jiri Slaby
2016-09-22  7:11 ` [patch added to 3.12-stable] arm64: Define AT_VECTOR_SIZE_ARCH for ARCH_DLINFO Jiri Slaby
2016-09-22  7:11   ` Jiri Slaby
2016-09-22  7:11 ` [patch added to 3.12-stable] parisc: Fix order of EREFUSED define in errno.h Jiri Slaby
2016-09-22  7:11 ` [patch added to 3.12-stable] PCI: Support PCIe devices with short cfg_size Jiri Slaby
2016-09-22  7:11 ` [patch added to 3.12-stable] PCI: Add Netronome vendor and device IDs Jiri Slaby
2016-09-22  7:11 ` [patch added to 3.12-stable] PCI: Limit config space size for Netronome NFP6000 family Jiri Slaby
2016-09-22  7:11 ` [patch added to 3.12-stable] PCI: Add Netronome NFP4000 PF device ID Jiri Slaby
2016-09-22  7:11 ` [patch added to 3.12-stable] PCI: Limit config space size for Netronome NFP4000 Jiri Slaby
2016-09-22  7:11 ` Jiri Slaby [this message]
2016-09-22  7:11 ` [patch added to 3.12-stable] usb: define USB_SPEED_SUPER_PLUS speed for SuperSpeedPlus USB3.1 devices Jiri Slaby
2016-09-22  7:11 ` [patch added to 3.12-stable] USB: validate wMaxPacketValue entries in endpoint descriptors Jiri Slaby
2016-09-22  7:11 ` [patch added to 3.12-stable] usb: xhci: Fix panic if disconnect Jiri Slaby
2016-09-22  7:11 ` [patch added to 3.12-stable] USB: serial: fix memleak in driver-registration error path Jiri Slaby
2016-09-22  7:11 ` [patch added to 3.12-stable] USB: serial: option: add D-Link DWM-156/A3 Jiri Slaby
2016-09-22  7:11 ` [patch added to 3.12-stable] USB: serial: option: add support for Telit LE920A4 Jiri Slaby
2016-09-22  7:11 ` [patch added to 3.12-stable] USB: serial: ftdi_sio: add device ID for WICED USB UART dev board Jiri Slaby
2016-09-22  7:11 ` [patch added to 3.12-stable] USB: serial: ftdi_sio: add PIDs for Ivium Technologies devices Jiri Slaby
2016-09-22  7:11 ` [patch added to 3.12-stable] xhci: Make sure xhci handles USB_SPEED_SUPER_PLUS devices Jiri Slaby
2016-09-22  7:11 ` [patch added to 3.12-stable] EDAC: Increment correct counter in edac_inc_ue_error() Jiri Slaby
2016-09-22  7:11 ` [patch added to 3.12-stable] s390/dasd: fix hanging device after clear subchannel Jiri Slaby
2016-09-22  7:11 ` [patch added to 3.12-stable] mac80211: fix purging multicast PS buffer queue Jiri Slaby
2016-09-22  7:11 ` [patch added to 3.12-stable] aacraid: Check size values after double-fetch from user Jiri Slaby
2016-09-22  7:11 ` [patch added to 3.12-stable] cdc-acm: fix wrong pipe type on rx interrupt xfers Jiri Slaby
2016-09-22  7:11 ` [patch added to 3.12-stable] megaraid_sas: Fix probing cards without io port Jiri Slaby
2016-09-22  7:11 ` [patch added to 3.12-stable] gpio: Fix OF build problem on UM Jiri Slaby
2016-09-22  7:11 ` [patch added to 3.12-stable] fs/seq_file: fix out-of-bounds read Jiri Slaby
2016-09-22  7:11 ` [patch added to 3.12-stable] Input: i8042 - break load dependency between atkbd/psmouse and i8042 Jiri Slaby
2016-09-22 16:37   ` Dmitry Torokhov
2016-09-23  8:23     ` Jiri Slaby
2016-09-22  7:11 ` [patch added to 3.12-stable] crypto: nx - off by one bug in nx_of_update_msc() Jiri Slaby
2016-09-22  7:11 ` [patch added to 3.12-stable] USB: fix typo in wMaxPacketSize validation Jiri Slaby
2016-09-22  7:11 ` [patch added to 3.12-stable] USB: serial: mos7720: fix non-atomic allocation in write path Jiri Slaby
2016-09-22  7:11 ` [patch added to 3.12-stable] USB: serial: mos7840: " Jiri Slaby
2016-09-22  7:11 ` [patch added to 3.12-stable] staging: comedi: daqboard2000: bug fix board type matching code Jiri Slaby
2016-09-22  7:11 ` [patch added to 3.12-stable] ACPI / sysfs: fix error code in get_status() Jiri Slaby
2016-09-22  7:11 ` [patch added to 3.12-stable] Revert "can: fix handling of unmodifiable configuration options fix" Jiri Slaby
2016-09-22  7:11 ` [patch added to 3.12-stable] be2iscsi: Fix bogus WARN_ON length check Jiri Slaby
2016-09-22  7:11 ` [patch added to 3.12-stable] HID: hid-input: Add parentheses to quell gcc warning Jiri Slaby
2016-09-22  7:11 ` [patch added to 3.12-stable] ALSA: oxygen: Fix logical-not-parentheses warning Jiri Slaby
2016-09-22  7:11 ` [patch added to 3.12-stable] stb6100: fix buffer length check in stb6100_write_reg_range() Jiri Slaby
2016-09-22  7:11 ` [patch added to 3.12-stable] ext4: validate that metadata blocks do not overlap superblock Jiri Slaby
2016-09-22  7:11 ` [patch added to 3.12-stable] s390/sclp_ctl: fix potential information leak with /dev/sclp Jiri Slaby
2016-09-22  7:11 ` [patch added to 3.12-stable] fix d_walk()/non-delayed __d_free() race Jiri Slaby

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=20160922071154.1297-10-jslaby@suse.cz \
    --to=jslaby@suse.cz \
    --cc=felipe.balbi@linux.intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.