Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp321082ybl; Thu, 12 Dec 2019 19:08:01 -0800 (PST) X-Google-Smtp-Source: APXvYqwtDWVbp3wHsJOVJP3EEGXyARQDoLv3dc39YOcfb4wIrx4YAw4mCuoNIdRLhD+fBKb/QQ5z X-Received: by 2002:a05:6830:60f:: with SMTP id w15mr12145135oti.225.1576206481817; Thu, 12 Dec 2019 19:08:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576206481; cv=none; d=google.com; s=arc-20160816; b=FHrEbnGrMmDfTzGyP7yL8/S3/sAWPbvkvG9Z/EIPtxeSzQCu5mc1vdUwvBvt4zuU/B WEb6DX9FaGvwdxbhtn3Q5jUNP53YS7nxMQzxpDKbK0MBFIbvCK1jrkVSRMJK5M8fLwxa KJk+QrmfnzCj8huptC9wqqN6HEHAzSMzaFe2ZNJEll+stM2y6LdY22SXyWTaQK29e4jr drtrFiNaxLm+OYx6p/ZenwLzNaWJGV7Nqjf35cNx3duxpFIZnzbDPiZBlDBrEdv+7/to 3UGi3wub8xmuiaukc5KWYnTgOVjLeoDeqgD0zDV6ss7gnodeDRMzkeheNWMoG9GJvUeg g44A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=WwpeGjmnfuoMNodJxH1qqlcQ4ceXry1kM/GE4cUt360=; b=ITpMUIPyLrateV49j43ZT7Z2bsl8dTqNMY0Y/jbqbUrHfLbpHU6UMLvqQGK0H/UkTL A3codXV85YIfoEgXlQJel+4CLHxA12CsIAxb1JVQE8PTdA4OxR5eSIZSCbGFj/AZifrK iRq79TGKqMjBdua4gncsmn86S4JELm7Us3WYITrRS9ZaWIJNgNYIdnRmQhUNolUs2YQp jhEa1gQ+qFdh1shJbl6QtFXaWXHakme3DlNM9bosUfSBWRdWjqiaNhY/wLVG1RoknLso TV2HtugECsODjvG7esHndZ1alD1kkyVLfJMLZoMEcqoh2QuAmsU02yosZnEUnaVOFEfK pI5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="Ig/3FDil"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q12si4287279otm.261.2019.12.12.19.07.49; Thu, 12 Dec 2019 19:08:01 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="Ig/3FDil"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731728AbfLMCbi (ORCPT + 99 others); Thu, 12 Dec 2019 21:31:38 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:40422 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731330AbfLMCbi (ORCPT ); Thu, 12 Dec 2019 21:31:38 -0500 Received: by mail-pf1-f194.google.com with SMTP id q8so621698pfh.7; Thu, 12 Dec 2019 18:31:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WwpeGjmnfuoMNodJxH1qqlcQ4ceXry1kM/GE4cUt360=; b=Ig/3FDil1XBe7TMbnNFatTTHH+Z4vR6bke278InL188wJrQ9DO5uhXv/3Xe8HKpnHi 4ev8PfRD1/0LIGHsIAc/uMJ4MgVI0TdXytpWOXxBCXyu24OHQrGXM8/99aPYX/XVVk2a 3iBzk7hq04axFjOQOJg/xUe2tV2rCYgweb7qup0RKABAAWLab9/mRLket5lUdFcEWdUs F1il50L8w/iI6dQSRCENr4/7t48MYNmg+VO/GGoaicnTpQjOJeor5MyjGCA9w43Wjl6F n3sAMZInzhiAdh7kuOaaF/aPA9NEg2EcB48Zysx8Wjohw2Kz9m9CqtwTJN9rFYgEUlvH FAdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WwpeGjmnfuoMNodJxH1qqlcQ4ceXry1kM/GE4cUt360=; b=hwV+/d1x4AFQNbRxHj938a+0Wbbn2xoKDchFfZU3Ghy2WWLMxBNrKy5BLlmogZDYht Q8ttysH6ndc+cae4eVZ4aLHN3EKzB6J+f99ML5TnjLVh3C3qAQ4edX36wnW3YxZ7pV3m xLUNBC2tcTkINWUtfD0FazRQWRDmE/SPD1+wDyU6ZZGC4HP3yQZdpvMpaz6e90BaihU1 KaoTO3mMe9MsP/ioR+QUkYyAiS5moPLnnRsilBcOlbiAl5MY2+WiM9Mk0HJHLpgR0WqY c/qagrutNqkryuPxeKgMr04LStcu+dB9EgUElgNSuj5+FWzSNHwj1ucAofzyCK8+xAdv oovA== X-Gm-Message-State: APjAAAVvsOULSpB2BNcu7aqjYeglCXHSpVM2/mafYv5tyHxxrr2XoJ21 9oT0ukPAsJLeKI2mBeDUICc= X-Received: by 2002:a65:5608:: with SMTP id l8mr14517216pgs.210.1576204297724; Thu, 12 Dec 2019 18:31:37 -0800 (PST) Received: from localhost.localdomain ([163.152.162.99]) by smtp.gmail.com with ESMTPSA id h68sm9443654pfe.162.2019.12.12.18.31.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Dec 2019 18:31:37 -0800 (PST) From: Suwan Kim To: shuah@kernel.org, valentina.manea.m@gmail.com, gregkh@linuxfoundation.org, marmarek@invisiblethingslab.com Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, stern@rowland.harvard.edu, Suwan Kim Subject: [PATCH v2 1/2] usbip: Fix receive error in vhci-hcd when using scatter-gather Date: Fri, 13 Dec 2019 11:30:54 +0900 Message-Id: <20191213023055.19933-2-suwan.kim027@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191213023055.19933-1-suwan.kim027@gmail.com> References: <20191213023055.19933-1-suwan.kim027@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When vhci uses SG and receives data whose size is smaller than SG buffer size, it tries to receive more data even if it acutally receives all the data from the server. If then, it erroneously adds error event and triggers connection shutdown. vhci-hcd should check if it received all the data even if there are more SG entries left. So, check if it receivces all the data from the server in for_each_sg() loop. Fixes: ea44d190764b ("usbip: Implement SG support to vhci-hcd and stub driver") Reported-by: Marek Marczykowski-Górecki Tested-by: Marek Marczykowski-Górecki Signed-off-by: Suwan Kim --- drivers/usb/usbip/usbip_common.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/usb/usbip/usbip_common.c b/drivers/usb/usbip/usbip_common.c index 6532d68e8808..e4b96674c405 100644 --- a/drivers/usb/usbip/usbip_common.c +++ b/drivers/usb/usbip/usbip_common.c @@ -727,6 +727,9 @@ int usbip_recv_xbuff(struct usbip_device *ud, struct urb *urb) copy -= recv; ret += recv; + + if (!copy) + break; } if (ret != size) -- 2.20.1