Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp313854ybl; Thu, 12 Dec 2019 18:59:46 -0800 (PST) X-Google-Smtp-Source: APXvYqyYVYh68cGiez+XNbV8ThCryATHUrDt4pH04sGrNLalPg6bR6yTy9oDUG3Zq31T0RJmxMnD X-Received: by 2002:a9d:366:: with SMTP id 93mr12248895otv.183.1576205985897; Thu, 12 Dec 2019 18:59:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576205985; cv=none; d=google.com; s=arc-20160816; b=DbMx/+j6yyM4ouhJD38pxqOEhX5QMzM0FL8tet/Yi/DQNtLKsdNmosma+gaxzFuKBu PpyOpTfkrMNAKP2wbzVjn3yr5KeHoLTAbMEwjoCWLuu9HnaslLIVwbFZClulrU8kGGtB M2mUYEWjkU9pw9xuPdZJ4ZpE4Ghob0qq8DklaurrNcLJdVYumdCowqF1sAK7/9BXb5bD 3eEX4FJcVB3xFFu8bmG6XkCzQn3Mu+fj3Gzg31A9knfRdEBv+4FWQVRYg4ySCuXsDKdn LwNFGjvPd5XuxJ/YaUyFFpyWwZ/hiAyhHc7ynPNfBdlaJJoVfPQCNYqie3N6L5JXECUR WVpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=sbQiyJc/inLjRaokZh7Q8U9UkbILv57sjMdX8isP4Mo=; b=aaB+wAH/KxL/Tjxm3p5rKCVO0XwsPuKTexsCQ8qI1QDMAVj6HxEAQqyjiahPDbD7/F XIL3QoHOKuGgQo9+h2NZlEhY0BDbFD5AcL6Cwp0gxDJdME0yJl5sJYxA3pFGFFyANFg9 PkqZGSo4FrTMqoUUzFqJIzXmPYkQ30PKWx4z69A1nFa3QgqyKbK5nlXG741Pp+kerpqS UtqWNZreHlMRYb2e0hH/pjN6igLODA2SxEqOGtRgpQwj2QQRakV/pz27omPHmjpK/YYW p0lfsknddSNuDnG2IHMdv5Rdh/A1EP+2GtKN4DBfesV+g13EfVmu+MB5OWORfiVu44IU ioog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="GoJvGU/p"; 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 n2si4234919otk.177.2019.12.12.18.59.33; Thu, 12 Dec 2019 18:59:45 -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="GoJvGU/p"; 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 S1731863AbfLMCD3 (ORCPT + 99 others); Thu, 12 Dec 2019 21:03:29 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:38363 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727084AbfLMCD3 (ORCPT ); Thu, 12 Dec 2019 21:03:29 -0500 Received: by mail-pg1-f193.google.com with SMTP id a33so727656pgm.5; Thu, 12 Dec 2019 18:03:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=sbQiyJc/inLjRaokZh7Q8U9UkbILv57sjMdX8isP4Mo=; b=GoJvGU/pGNn2G/E7yRVTN1E+5omlN/INnTODmiCukTeBCtVV93jNiI7auavjP+VNfB LKgnRr0LrIWAlifLg+wn9qlbpcx5pX5DWp5PRQQP7Ls6cKQBjx2LrLq8DLpBk21Fd8ey dsV8/8EZZ61gPmzFEHciUaWIgk1LGUkGxzuPiG+tAPvBE/M5npuCcN3qRIsPPPyRQr7K FUwh1+V/brjSEO4pMmIZXDFGSRd8P5DaZW5m6gMnxaSKJXgjnI41DRCgJqlowmdWrvJ3 cyZrZutJtW3mSVFgRujqCTgKJuzeC+ymvIXoRuoz08F3C2DfWGk0PtGXIlRETRyClng3 6fcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=sbQiyJc/inLjRaokZh7Q8U9UkbILv57sjMdX8isP4Mo=; b=nPeMmsSuIqPp/qyH3/msJ/1UvooVR6BsmWK34EMt/6hSBseITRbuTj3waCBOqEgShU YzbjyhqCutcJo/KPd3lPtIQwun6PDmeMcaBynqU3hr1vmkwYb/JrZ+MhM0xzKMiV5UbL GR027jF3Uc5SwFkSpTb+9fOdrPLtwTOK0Qup6M2x7SVIWmQgw+Mx34yFDeWIlQEo5ayI CZ00HQCZV7ZVQ9Pn6GvbG52dKiznC6DZ3UC5abi571h/aNmjmUzwFELxZD6+rvHWy/XW 0P5fVWM1vMJDBg/bKGKxAof7lFd4sB/CK1oiZydK3v/9aPg7jRDm1H0NdpRovUSbKrMW m38Q== X-Gm-Message-State: APjAAAVVXqFIJ9qmrV5obh2CDEFKjZWB2iMj3EpjlS8EMDKKdfsDmcnL hkOIGGD5tA7L/hT2h0ZWIlE= X-Received: by 2002:a63:5950:: with SMTP id j16mr14651502pgm.314.1576202608242; Thu, 12 Dec 2019 18:03:28 -0800 (PST) Received: from localhost.localdomain ([163.152.162.99]) by smtp.gmail.com with ESMTPSA id i68sm8886098pfe.173.2019.12.12.18.03.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Dec 2019 18:03:27 -0800 (PST) Date: Fri, 13 Dec 2019 11:03:17 +0900 From: Suwan Kim To: Alan Stern Cc: shuah@kernel.org, valentina.manea.m@gmail.com, gregkh@linuxfoundation.org, marmarek@invisiblethingslab.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH 2/2] usbip: Fix error path of vhci_recv_ret_submit() Message-ID: <20191213020317.GA3276@localhost.localdomain> References: <20191212052841.6734-3-suwan.kim027@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.12.1 (2019-06-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Dec 12, 2019 at 10:54:08AM -0500, Alan Stern wrote: > On Thu, 12 Dec 2019, Suwan Kim wrote: > > > If a transaction error happens in vhci_recv_ret_submit(), event > > handler closes connection and changes port status to kick hub_event. > > Then hub tries to flush the endpoint URBs, but that causes infinite > > loop between usb_hub_flush_endpoint() and vhci_urb_dequeue() because > > "vhci_priv" in vhci_urb_dequeue() was already released by > > vhci_recv_ret_submit() before a transmission error occurred. Thus, > > vhci_urb_dequeue() terminates early and usb_hub_flush_endpoint() > > continuously calls vhci_urb_dequeue(). > > > > The root cause of this issue is that vhci_recv_ret_submit() > > terminates early without giving back URB when transaction error > > occurs in vhci_recv_ret_submit(). That causes the error URB to still > > be linked at endpoint list without “vhci_priv". > > > > So, in the case of trasnaction error in vhci_recv_ret_submit(), > > unlink URB from the endpoint, insert proper error code in > > urb->status and give back URB. > > > > Reported-by: Marek Marczykowski-Górecki > > Signed-off-by: Suwan Kim > > --- > > drivers/usb/usbip/vhci_rx.c | 13 +++++++++---- > > 1 file changed, 9 insertions(+), 4 deletions(-) > > > > diff --git a/drivers/usb/usbip/vhci_rx.c b/drivers/usb/usbip/vhci_rx.c > > index 33f8972ba842..dc26acad6baf 100644 > > --- a/drivers/usb/usbip/vhci_rx.c > > +++ b/drivers/usb/usbip/vhci_rx.c > > @@ -77,16 +77,21 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev, > > usbip_pack_pdu(pdu, urb, USBIP_RET_SUBMIT, 0); > > > > /* recv transfer buffer */ > > - if (usbip_recv_xbuff(ud, urb) < 0) > > - return; > > + if (usbip_recv_xbuff(ud, urb) < 0) { > > + urb->status = -EPIPE; > > + goto error; > > + } > > > > /* recv iso_packet_descriptor */ > > - if (usbip_recv_iso(ud, urb) < 0) > > - return; > > + if (usbip_recv_iso(ud, urb) < 0) { > > + urb->status = -EPIPE; > > + goto error; > > + } > > -EPIPE is used for STALL. The appropriate error code for transaction > error would be -EPROTO (or -EILSEQ or -ETIME, but people seem to be > settling on -EPROTO). Thanks for the feedback. I will fix it :) Regards, Suwan Kim