Received: by 10.223.185.116 with SMTP id b49csp1141792wrg; Fri, 23 Feb 2018 12:40:58 -0800 (PST) X-Google-Smtp-Source: AH8x227nyMWRMzGQwI3JRo3HykNmYz25H/hcBFA+1m5ccVo3aBPpOpSy/Hqm9cW/YSIEVbbzAHL+ X-Received: by 2002:a17:902:b2c6:: with SMTP id x6-v6mr2796302plw.285.1519418458574; Fri, 23 Feb 2018 12:40:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519418458; cv=none; d=google.com; s=arc-20160816; b=UCgNyTbNC1gNAcHMP07JdC0gjj86F3dJLN9pmu6/UL9XN6vdcl7a7QWloYNWMRpCsf 4hQSp5pStdkCQDj14dtznmoPqynFvo/bScoRO2L/SGtpI4ui6ca/ADA6wBdGWhDI68nF PTo18K/7awXpIgo7EP9YVyoIzIcjh0JEuhm7oL26RrHGyyXhSgkEnRlJnNooPOSG2Cct ecdsEEOu5XV9QVCXJ6bTms1Yp5QXQ2UQSuYE+NFOcbyQhaMHD5FcYkSnyoVaTaKM8ZqD OREgxDyYyKYx16xiHig2Rldp6RDMlS0tia60r2qg1NkuXex77UHv8LwC9S+8ZRjvMxcd 0ZBA== 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=dKGWQdsAHE4ADxYjxNoqoOolS+aXuDH+T7A3SjaBRCo=; b=KfdXPyyxOge1C33CThPonNhfzMx9SQOY1C+h95idY+Se6C9HzuR/bs4/49ZHRqHC04 VrJntqh+GZY8zgDck2QOsqh8rXaNLedttl9FHjOQ41RhWALBVsugw5Nmt0ISSIidUCHB 8bdiWkck6oBPKJNd7oGfWwpnmpcNhUwad2s+vPUqt2iZfl9L0OyX/kCwu51O4MpLGht/ 20AWdCwB0dOvW6BRWJPdO0Qw/TC3Wazz+5JCEU+fFO576ZvY954RE6kd6LxhG/6eKlJP KQGt6z5BmYdPveRN+hjRhjTt7oeKiQWkVI6FomazwafQBI7dZSMVhh+SU1xqJ5iq500Y zn8A== 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 a62si1939149pgc.70.2018.02.23.12.40.44; Fri, 23 Feb 2018 12:40:58 -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 S1753519AbeBWUkI (ORCPT + 99 others); Fri, 23 Feb 2018 15:40:08 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:36704 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752671AbeBWSdy (ORCPT ); Fri, 23 Feb 2018 13:33:54 -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 3BA511164; Fri, 23 Feb 2018 18:33:53 +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.4 029/193] usbip: keep usbip_device sockfd state in sync with tcp_socket Date: Fri, 23 Feb 2018 19:24:22 +0100 Message-Id: <20180223170330.617450280@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180223170325.997716448@linuxfoundation.org> References: <20180223170325.997716448@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.4-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 @@ -797,6 +797,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"); @@ -844,6 +845,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;