Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp980396ybl; Thu, 12 Dec 2019 07:54:50 -0800 (PST) X-Google-Smtp-Source: APXvYqxy6aLPM9q1rhFgXVievwYpoGKtSs3wmCzE88fRD6qQUF3OD95U2mNSUO3RLbCtvJwjRKW0 X-Received: by 2002:aca:d4ca:: with SMTP id l193mr5511232oig.133.1576166090353; Thu, 12 Dec 2019 07:54:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576166090; cv=none; d=google.com; s=arc-20160816; b=bE6jqZ/B6kMW3WDF7e49exWMnbsum6RUDopT+cngFQapvjnijoiNfCC0Glid9UwtZh EcxTjAIhxShScsvlgraYHtott+b/TMFSyYYAxF6aP2wvse4d3vG1Ym+m9oASTxO9Rg/k 6rd7DjBsr3l1s6L2xdkcn2SruynAkFw/2mH1lTmAJGqzN/VLwwW4Yi+WHEAkAb2xJcAi jWujqcvpdYgrXXNu7QJG3V8hOhDJyGL9Bbu94dZZ68w/KKXi49WSwvFJ+8c7i2/wRopy +tf+brGmMf7/zoJrQeL3EumPlJ7aIFhQGbxbRaXu2LjREA/qD5fH5wvY4oJ6UPDBlbyb uY6w== 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 :message-id:in-reply-to:subject:cc:to:from:date; bh=H8LzSp7UHVg4fmMj9rPgeW4zX+6z1nnyf9RfhvnrB5g=; b=pdtzfBi2j398IKK0QUKfTQsR6czNaBh3vq3MLa/7QgbqZA1e1hQkjXiIp1DhTMGimV DvVRtFxZOkiT97ELvVa1K+ggr8LbzQBmi3xwgd+H0oTMg/Q6L6+dtffhgPQCZGCFum7q wcgP9bFF50OrMey9DaFC/d6+TK99I7SLfN5MMzdltvr5yoab0qZthqWanLP+0DWrHvlO QZJFaReb4GvsXuMqxpC5BPxaLrShCYods8UoO25U3FQataKhc3zvjq2/lBvNSqV6RxnE 8fkCsGSp6Il8cBk9julKKSxhnnHu+NawJ0WqzuVV2exBwj+vscKLKvBz4WxHw18QPuNn K3hA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k126si3395740oib.43.2019.12.12.07.54.37; Thu, 12 Dec 2019 07:54:50 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729557AbfLLPyJ (ORCPT + 99 others); Thu, 12 Dec 2019 10:54:09 -0500 Received: from netrider.rowland.org ([192.131.102.5]:55367 "HELO netrider.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1729498AbfLLPyJ (ORCPT ); Thu, 12 Dec 2019 10:54:09 -0500 Received: (qmail 17464 invoked by uid 500); 12 Dec 2019 10:54:08 -0500 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 12 Dec 2019 10:54:08 -0500 Date: Thu, 12 Dec 2019 10:54:08 -0500 (EST) From: Alan Stern X-X-Sender: stern@netrider.rowland.org To: Suwan Kim cc: shuah@kernel.org, , , , , , Subject: Re: [PATCH 2/2] usbip: Fix error path of vhci_recv_ret_submit() In-Reply-To: <20191212052841.6734-3-suwan.kim027@gmail.com> Message-ID: 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 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). Alan Stern