Received: by 10.223.185.116 with SMTP id b49csp1095593wrg; Fri, 23 Feb 2018 11:51:46 -0800 (PST) X-Google-Smtp-Source: AH8x2256ic+ZCU2Whc7yxA1HOBfkgBXLj12MpmMepjwY3oWFlKqcX9Q+i0BbW91tCoC0COsU7GSH X-Received: by 10.98.68.129 with SMTP id m1mr2731374pfi.171.1519415506233; Fri, 23 Feb 2018 11:51:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519415506; cv=none; d=google.com; s=arc-20160816; b=A3nt8teo3adoy48L5hfe5T06dCcCSG4xHD4tTQbecebTHvLmBiTyl0fhLJnSsrE1Xj YTqXRChLrxhhNVS6kbFYG+Kdj5bxHxrlSIkZ7axEYYKHPPa3ydoAeykkhgAOXUnKnin9 XF91Op/QnXYNIB58mjOXiHJdcicG9HLPb+EzNHNH6aVuIluQIlIfPRrh20bgxnJ4/4Qx Op/eRWt3Ymiqo/fdpVokEMk6I6gKgYW8yw3DcoSxYE3z7p+Ud9hNf03jmWfTc0ZByh7j cWzZjKug6SSB6zV+DwGNWcmX1AzngjuHenInUwgO+uthjSoI4t9mUX4XUK4odc13ayru K42A== 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=UpNuIGV2mdVHYklz7xPlXVMKaWnBODRoTR7iq76jqKo=; b=mKMneeYF982gX1H1G3gW3HYWCLvm62sZqkCdCLvdjw05v5UDD+/hoV9j2nxjTEffcz rkYCryCB5ABuBI7sw8uwX/bRsFv+XeJNnilc6+Hu9Z6wrGyOlD/QyBPipm0/ogtdMXlS LHYJP0PhalVo1+n2C78b9yWuKVuYZL3pWUZczZAzyTKZaJbpw6DlVAt3+Lq9kuycXpqz d25bD5Bgvp+gqn6MUNnmn2u3HwCnxMR/s70Py5dZIuEKAIv8XMfcA4kIe7sB6otOIPBm /e1oJQmw8+ddph95+WQjgxA/oJJ9M37jMrWHuCp88gRUKfeHNx5r72/HNkNG8dYJWh+e fncQ== 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 j13si2228985pfh.78.2018.02.23.11.51.31; Fri, 23 Feb 2018 11:51:46 -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 S933978AbeBWSqP (ORCPT + 99 others); Fri, 23 Feb 2018 13:46:15 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:43606 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933962AbeBWSqM (ORCPT ); Fri, 23 Feb 2018 13:46:12 -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 2D71F1244; Fri, 23 Feb 2018 18:46:12 +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.9 041/145] usbip: keep usbip_device sockfd state in sync with tcp_socket Date: Fri, 23 Feb 2018 19:25:47 +0100 Message-Id: <20180223170730.211970857@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180223170724.669759283@linuxfoundation.org> References: <20180223170724.669759283@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.9-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 @@ -87,6 +87,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); @@ -186,6 +187,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 */ @@ -280,6 +282,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 @@ -832,6 +832,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"); @@ -879,6 +880,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;