Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp1145144pxv; Fri, 9 Jul 2021 19:26:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxioRXESl40Rl6KBo/C3QpC1GrcvEqObRtueuP5VWMHglWMEbxk2gQ6n48zA4WY+P+J5hBv X-Received: by 2002:a17:907:72c9:: with SMTP id du9mr25836131ejc.497.1625884011522; Fri, 09 Jul 2021 19:26:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625884011; cv=none; d=google.com; s=arc-20160816; b=KxMSx3FVJMK5XHVMgQDT53WavtCWas4kEOkaL8zuzKmnjQoGRBMmz767udfU6RRLYv ypzYEiAM7vIllWLyJiquKI+MafJRvAhATKvlPQYjKjS/V7A32kkExmY+pfPxRRutrIQe GEl32V2ndFC02numG/Z1puzWE8YBLbma2fuLPlgf4WsT+F+DFgZ7zFxzowRIuGRHKXle 0vObdDnjybioYU1yGx+3fE/xBHPOYqzhdXP/+Py4lBb3Efq93iDsQju5ddixzBDJZ+NL SIuAfRoZIRWNPty5itvNPRb1TjiKamJQQpNeNeXetogd7/ajnTXaZ/A+4Q3yWy1x+tUT HDvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=OBwq3xee7ug/ytqsvMeobAI04dIDs60fus5+kIXZsZA=; b=IfqXyFb0QbIU6N6RugFRA0STgaVnCwSujlOeQhScWL4ZABCLa2O/kUtivdxl57Zr7C On3z5oPEOFB45/AGGat450lic6UOk4/R+PZ1zMpN6iqQnS6Wuj9hDOw4xgSDPrYua/uC wagkOjZcKw36+8l4Hc4WTksTPVyOF8OqmB6XMOIFEbN7laoBt4QHSPA3Mrmfbt5kgmhT WjTDl5nhTuezde4x3QWe+hhd8qEbFBNIKScBy4xolALNJbuR5WHMYC8Yt5UMGTy9UQN8 Tx6KnXckvA5it3POwp7KxoQZrnAjid/WPsCVeH8h8aiJ2JK1HmN5+AphsAyv8cqVu227 t4Sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="XF/Xz+Dm"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y20si8714590ejr.227.2021.07.09.19.26.28; Fri, 09 Jul 2021 19:26:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="XF/Xz+Dm"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233729AbhGJC1s (ORCPT + 99 others); Fri, 9 Jul 2021 22:27:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:43192 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233266AbhGJC0b (ORCPT ); Fri, 9 Jul 2021 22:26:31 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 622D8613EE; Sat, 10 Jul 2021 02:23:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625883824; bh=wVFWZjD32RCEOXrQYqbhnw7dQOnDS4glSrjrbV4SPHo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XF/Xz+Dmweuf/emnq/LdQPZPYr5GdWtW1v/wywEIAioznrBBgg1Rg6Ks1wFyL2tJM nW5bRopze2jTPa6d87Dx02T9HpHE3tTpqyMWti0TpimqsjylnAbjDz29FyO0+3I4O2 00R3+O00W9xOxMBkbgu5GPN6QvBtFckCafewxyXig1yw6Hi16TT+kzoR83GkemrnZj 9fFXSgL4tTGa5eGuvJtncJHCbVP0W+Oj+ebbzW2FG33CbT5HgqUfQjbcTL8lcboldn aKDbIbfkdkiTxF/8MY11sQBGv9WTdFQNWDfBOUZepUoc6cAbZbMf0eh3STvwv7tJfu AjRZ9GrtEST/w== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Mathias Nyman , Greg Kroah-Hartman , Sasha Levin , linux-usb@vger.kernel.org Subject: [PATCH AUTOSEL 5.12 072/104] xhci: handle failed buffer copy to URB sg list and fix a W=1 copiler warning Date: Fri, 9 Jul 2021 22:21:24 -0400 Message-Id: <20210710022156.3168825-72-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210710022156.3168825-1-sashal@kernel.org> References: <20210710022156.3168825-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mathias Nyman [ Upstream commit 271a21d8b280b186f8cc9ca6f7151902efde9512 ] Set the urb->actual_length to bytes successfully copied in case all bytes weren't copied from a temporary buffer to the URB sg list. Also print a debug message Signed-off-by: Mathias Nyman Link: https://lore.kernel.org/r/20210617150354.1512157-4-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/usb/host/xhci.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 0d2f1c37ab74..73cdaa3f3067 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -1362,12 +1362,17 @@ static void xhci_unmap_temp_buf(struct usb_hcd *hcd, struct urb *urb) urb->transfer_buffer_length, dir); - if (usb_urb_dir_in(urb)) + if (usb_urb_dir_in(urb)) { len = sg_pcopy_from_buffer(urb->sg, urb->num_sgs, urb->transfer_buffer, buf_len, 0); - + if (len != buf_len) { + xhci_dbg(hcd_to_xhci(hcd), + "Copy from tmp buf to urb sg list failed\n"); + urb->actual_length = len; + } + } urb->transfer_flags &= ~URB_DMA_MAP_SINGLE; kfree(urb->transfer_buffer); urb->transfer_buffer = NULL; -- 2.30.2