Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965978AbbDWOLE (ORCPT ); Thu, 23 Apr 2015 10:11:04 -0400 Received: from mail-lb0-f169.google.com ([209.85.217.169]:34549 "EHLO mail-lb0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934082AbbDWOJS (ORCPT ); Thu, 23 Apr 2015 10:09:18 -0400 From: Johan Hovold To: Greg Kroah-Hartman , Felipe Balbi , Alan Stern Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Stephen Warren , Thierry Reding , Alexandre Courbot , linux-tegra@vger.kernel.org, Johan Hovold Subject: [PATCH v2 3/3] staging: octeon-usb: fix unaligned isochronous transfers Date: Thu, 23 Apr 2015 16:06:52 +0200 Message-Id: <1429798012-21916-4-git-send-email-johan@kernel.org> X-Mailer: git-send-email 2.0.5 In-Reply-To: <1429798012-21916-1-git-send-email-johan@kernel.org> References: <1429798012-21916-1-git-send-email-johan@kernel.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1621 Lines: 46 Make sure to copy the whole transfer buffer when releasing the temporary buffer used for unaligned isochronous transfers as the data is not necessarily contiguous in that case. Signed-off-by: Johan Hovold --- drivers/staging/octeon-usb/octeon-hcd.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/staging/octeon-usb/octeon-hcd.c b/drivers/staging/octeon-usb/octeon-hcd.c index 1daeb3125a1f..e03873c343b1 100644 --- a/drivers/staging/octeon-usb/octeon-hcd.c +++ b/drivers/staging/octeon-usb/octeon-hcd.c @@ -509,15 +509,21 @@ static int octeon_alloc_temp_buffer(struct urb *urb, gfp_t mem_flags) static void octeon_free_temp_buffer(struct urb *urb) { struct octeon_temp_buffer *temp; + size_t length; if (!(urb->transfer_flags & URB_ALIGNED_TEMP_BUFFER)) return; temp = container_of(urb->transfer_buffer, struct octeon_temp_buffer, data); - if (usb_urb_dir_in(urb)) - memcpy(temp->orig_buffer, urb->transfer_buffer, - urb->actual_length); + if (usb_urb_dir_in(urb)) { + if (usb_pipeisoc(urb->pipe)) + length = urb->transfer_buffer_length; + else + length = urb->actual_length; + + memcpy(temp->orig_buffer, urb->transfer_buffer, length); + } urb->transfer_buffer = temp->orig_buffer; urb->transfer_flags &= ~URB_ALIGNED_TEMP_BUFFER; kfree(temp->temp_buffer); -- 2.0.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/