]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
usbip: keep usbip_device sockfd state in sync with tcp_socket
authorShuah Khan <shuahkh@osg.samsung.com>
Fri, 26 Jan 2018 18:56:50 +0000 (11:56 -0700)
committerSasha Levin <alexander.levin@microsoft.com>
Sun, 4 Mar 2018 15:28:25 +0000 (10:28 -0500)
[ Upstream commit 009f41aed4b3e11e6dc1e3c07377a10c20f1a5ed ]

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 <shuahkh@osg.samsung.com>
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
drivers/usb/usbip/stub_dev.c
drivers/usb/usbip/vhci_hcd.c

index ec38370ffcab9587e1ba910e68375eebe8bb6403..0931f32711198965cf00a79f0f40b8819ea3eb32 100644 (file)
@@ -87,6 +87,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);
 
@@ -186,6 +187,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 */
@@ -280,6 +282,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);
index 0231507837feff6db25460c6a2f80b0dff14fa49..17498af82b69e5e188ad1216698810bf1a83e0b1 100644 (file)
@@ -780,6 +780,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");
 
@@ -826,6 +827,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;