Received: by 10.223.176.46 with SMTP id f43csp1047509wra; Fri, 26 Jan 2018 10:58:33 -0800 (PST) X-Google-Smtp-Source: AH8x2243JK+f6fuQHTYKy2T/Y0yxneafooNaa7+pU0YVwP1ag/JkUIgOkigTkOLHCpjn7Wd+E/cF X-Received: by 10.99.126.26 with SMTP id z26mr16085411pgc.151.1516993113483; Fri, 26 Jan 2018 10:58:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516993113; cv=none; d=google.com; s=arc-20160816; b=Z1p1NAL7DPt6HSudOGOhaHxIRXf+A47moHAtfImHogLHvf+sWqEMZpvvG/vdmbmpQB UkXFAusNH/9/l4/JrnDbJzeLPG1RsjYuuUfnWKBqNanxgCLTCTxSomKaRJ67gcodZ6Pe Vu21ETMdQB7gOOqb+hk4hniJG03GSMfAjQFUg/WH8RSgKUwj0If2YuFAmHXia0vRtdX/ D7iRMRNtbB9u/29hkWIgW6+3nI6XeXnWl+MskKfDatmPVmA8FtJz8Jh4rIgkqfQ1bbFR t+7whtDckxc/sqWaPp//pU+NEwN6eMsgFSYcW2trgmLeqYFgYYJIsXfUOsVJuWzHiuy5 VK4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=nrrgldxb3r5Ntcq2mP81NL6aEcSFU3gQGv0NSAe6ht4=; b=djREovmnM9Grjls/xBM+mqyV91AWKFEv3fXkMifRy0dn16aqV3sbHBiqZ/M1cXkDzv sl07qUAauR5W1qwIgwgrJ4/Tgxxt6FSKY1qjxMx9TuxnAqXzV7RXHFaz8UuUAkR86bdT 9cL/LgHzY9yOD9IPZJT0g3H+a0DnKeRG3AJCGszlVFB4vlLO8QATc5FkXTfNQ6wLt+l/ d4O6G8Y3alVtVDiXpv8Jnlzz5oMM/bIRo4SR4k1ymHEEkqCe1nLpIGo+g51uRvK3W9FU CDzMAcvRT1P/Kerse2HbF4Geiklbc1BlDFDi8f1TlMDmMHw6FsbFSkp7DFJVepVtQXnf gl+w== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w3si3318907pgb.739.2018.01.26.10.58.19; Fri, 26 Jan 2018 10:58:33 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752623AbeAZS5R (ORCPT + 99 others); Fri, 26 Jan 2018 13:57:17 -0500 Received: from osg.samsung.com ([64.30.133.232]:36276 "EHLO osg.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752496AbeAZS5P (ORCPT ); Fri, 26 Jan 2018 13:57:15 -0500 Received: from localhost (localhost [127.0.0.1]) by osg.samsung.com (Postfix) with ESMTP id 43F671A8B6; Fri, 26 Jan 2018 10:57:15 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at dev.s-opensource.com Received: from osg.samsung.com ([127.0.0.1]) by localhost (localhost [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Gm4JL6zgZQ9c; Fri, 26 Jan 2018 10:57:13 -0800 (PST) Received: from localhost.localdomain (c-24-9-64-241.hsd1.co.comcast.net [24.9.64.241]) by osg.samsung.com (Postfix) with ESMTPSA id 1B37F1A8AA; Fri, 26 Jan 2018 10:57:13 -0800 (PST) From: Shuah Khan To: valentina.manea.m@gmail.com, shuah@kernel.org, gregkh@linuxfoundation.org Cc: Shuah Khan , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH] usbip: keep usbip_device sockfd state in sync with tcp_socket Date: Fri, 26 Jan 2018 11:56:50 -0700 Message-Id: <20180126185650.15752-1-shuahkh@osg.samsung.com> X-Mailer: git-send-email 2.14.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/usb/usbip/stub_dev.c | 3 +++ drivers/usb/usbip/vhci_hcd.c | 2 ++ 2 files changed, 5 insertions(+) diff --git a/drivers/usb/usbip/stub_dev.c b/drivers/usb/usbip/stub_dev.c index e31a6f204397..86037e5b1101 100644 --- a/drivers/usb/usbip/stub_dev.c +++ b/drivers/usb/usbip/stub_dev.c @@ -73,6 +73,7 @@ static ssize_t store_sockfd(struct device *dev, struct device_attribute *attr, 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(struct usbip_device *ud) 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_alloc(struct usb_device *udev) 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); diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c index c3e1008aa491..20e3d4609583 100644 --- a/drivers/usb/usbip/vhci_hcd.c +++ b/drivers/usb/usbip/vhci_hcd.c @@ -984,6 +984,7 @@ static void vhci_shutdown_connection(struct usbip_device *ud) 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 usbip_device *ud) if (ud->tcp_socket) { sockfd_put(ud->tcp_socket); ud->tcp_socket = NULL; + ud->sockfd = -1; } ud->status = VDEV_ST_NULL; -- 2.14.1