Received: by 10.223.185.116 with SMTP id b49csp1053854wrg; Fri, 23 Feb 2018 11:04:00 -0800 (PST) X-Google-Smtp-Source: AH8x224AI5EqWkPc/s40G6yzUryqLILNi2a3nIQ6rDVcP8czePs4g4GDUP2nD7WLNJaRHQ/mYLPe X-Received: by 2002:a17:902:8f95:: with SMTP id z21-v6mr2626095plo.132.1519412640320; Fri, 23 Feb 2018 11:04:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519412640; cv=none; d=google.com; s=arc-20160816; b=tyiD0nk3XOGqZp6w2IGsaIRs49VZu/m+c4T7HUxCIIcOriXT58S+nR2jbWmUqD/0kN BJP5T2ZJ/IgAH8Hy9Oww+tKPIctyNcjArezKjlpM/uXAVYQjb0Rir3L5sKBasGPBrINI r6pD/Zh24/hI4pe7eIIlGQIT4CKYOjmJxBu/8uh1S35MQE5wQQK4/F5mewbbKXWmS7wv ksBEGSXy4rSXnOPOUNWzRnKkkeZ+8WGzkB2i/5NWypmbH2WQ1yZVIYj1w1paOucMGp8O l8coAtSb6o2cVl5M9ms0cwaMYwiyn+68DwY1XuVJmxliGMpAbOWMVgQMjDOuzCyDp9Co adZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=1ir5Y+4lagmAwwRuPdMGE3C8X+s7Q2tu2XHl6VWqh1k=; b=xSI9X74QE/U2N3vp0UqHXkko4wdITvnM2Ofh6f2w2RzmILeMyuHEQ+GAE21NtZo0S7 zejG7GzAuChVruLvfCp8Fwehvv4/Nx3cIRfHaivG1H0+4zZTCWTn4UI5EsRrIutcUnyd J9E4+dD7nHwCrwwMNaOrQ+AHmQwSL60o1lfPSp0ysplURVQqfsWvqNdPYqujxFFS4ijT XzbS+rrTZb4i3kB3JXo86PEEf2ctvi7iyZ6T74kEqiNBkn5xPs6TsiBn81ucIelTd48M NuJ/MA29pVgJYFAvh5y+UbSGVnaqDEuHUduNWVRsiT63MOmvHL1LsHuP+0RPdGDiEQEe 6faA== 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 63si1828027pgi.596.2018.02.23.11.03.46; Fri, 23 Feb 2018 11:04:00 -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 S965678AbeBWS6t (ORCPT + 99 others); Fri, 23 Feb 2018 13:58:49 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:50658 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965656AbeBWS6o (ORCPT ); Fri, 23 Feb 2018 13:58:44 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 711B010FD; Fri, 23 Feb 2018 18:58:43 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Shuah Khan Subject: [PATCH 4.15 41/45] usbip: keep usbip_device sockfd state in sync with tcp_socket Date: Fri, 23 Feb 2018 19:29:20 +0100 Message-Id: <20180223170721.895702679@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180223170715.197760019@linuxfoundation.org> References: <20180223170715.197760019@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Shuah Khan commit 009f41aed4b3e11e6dc1e3c07377a10c20f1a5ed upstream. Keep usbip_device sockfd state in sync with tcp_socket. When tcp_socket is reset to null, reset sockfd to -1 to keep it in sync. Signed-off-by: Shuah Khan Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/usbip/stub_dev.c | 3 +++ drivers/usb/usbip/vhci_hcd.c | 2 ++ 2 files changed, 5 insertions(+) --- a/drivers/usb/usbip/stub_dev.c +++ b/drivers/usb/usbip/stub_dev.c @@ -73,6 +73,7 @@ static ssize_t store_sockfd(struct devic goto err; sdev->ud.tcp_socket = socket; + sdev->ud.sockfd = sockfd; spin_unlock_irq(&sdev->ud.lock); @@ -172,6 +173,7 @@ static void stub_shutdown_connection(str if (ud->tcp_socket) { sockfd_put(ud->tcp_socket); ud->tcp_socket = NULL; + ud->sockfd = -1; } /* 3. free used data */ @@ -266,6 +268,7 @@ static struct stub_device *stub_device_a sdev->ud.status = SDEV_ST_AVAILABLE; spin_lock_init(&sdev->ud.lock); sdev->ud.tcp_socket = NULL; + sdev->ud.sockfd = -1; INIT_LIST_HEAD(&sdev->priv_init); INIT_LIST_HEAD(&sdev->priv_tx); --- a/drivers/usb/usbip/vhci_hcd.c +++ b/drivers/usb/usbip/vhci_hcd.c @@ -984,6 +984,7 @@ static void vhci_shutdown_connection(str if (vdev->ud.tcp_socket) { sockfd_put(vdev->ud.tcp_socket); vdev->ud.tcp_socket = NULL; + vdev->ud.sockfd = -1; } pr_info("release socket\n"); @@ -1030,6 +1031,7 @@ static void vhci_device_reset(struct usb if (ud->tcp_socket) { sockfd_put(ud->tcp_socket); ud->tcp_socket = NULL; + ud->sockfd = -1; } ud->status = VDEV_ST_NULL;