From patchwork Thu Apr 23 14:06:52 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 463967 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 7E24514012F for ; Fri, 24 Apr 2015 00:11:03 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="verification failed; unprotected key" header.d=gmail.com header.i=@gmail.com header.b=UDzFJoni; dkim-adsp=none (unprotected policy); dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965073AbbDWOLC (ORCPT ); Thu, 23 Apr 2015 10:11:02 -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 Received: by lbcga7 with SMTP id ga7so14126868lbc.1; Thu, 23 Apr 2015 07:09:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=1UaLyMqswX9Qr0VDAu6L7FPIYBqKPy0hVWtUYauDK3E=; b=UDzFJonibFo1StvwQzDcP91n60NrUr7sB2mX6woWaRZie+FrLmemCXAGwx4qo5qIro yA3ajJhwPQnpYGuMbH/ieykrlg1FlvuwFnWSbHcpYdVx2MLwihEgq2eLA2l6i7ft3EIy qs4ttrmu9GucJsIH0xTH2PyJuHNPu2ET04Td2TAFZRocHzcOebSV64fdaTDfbrwDzE8/ PU7zyLBEuLTWhMk1/diC8d2F1FSX53Gy1p6Vy+3DFLJNL/PzHm3a7pbpB26KiVDYPSyz 68xWdAU9M8DKM79WkxdR/9lzc2LuTKx8yWyprp1a2BSAJSG0ntK7mF1EIEH7LDyIAzR+ mUWg== X-Received: by 10.112.17.68 with SMTP id m4mr2687061lbd.10.1429798157231; Thu, 23 Apr 2015 07:09:17 -0700 (PDT) Received: from xi.terra (c193-14-96-226.cust.tele2.se. [193.14.96.226]) by mx.google.com with ESMTPSA id c5sm1890270lac.15.2015.04.23.07.09.14 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Apr 2015 07:09:14 -0700 (PDT) Received: from johan by xi.terra with local (Exim 4.84) (envelope-from ) id 1YlHob-0005j3-R3; Thu, 23 Apr 2015 16:09:17 +0200 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-tegra-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-tegra@vger.kernel.org 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);