From e0901a872305c2fb0699112371a1688f2a532615 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 4 Mar 2012 11:57:41 +0100 Subject: [PATCH 19/35] usb-redir: Always clear device state on filter reject RH-Author: Hans de Goede Message-id: <1330862278-22314-5-git-send-email-hdegoede@redhat.com> Patchwork-id: 37919 O-Subject: [PATCH 04/21] usb-redir: Always clear device state on filter reject Bugzilla: 758104 RH-Acked-by: Hans de Goede RH-Acked-by: Gerd Hoffmann RH-Acked-by: Alon Levy RH-Acked-by: Markus Armbruster Always call usbredir_device_disconnect() when usbredir_check_filter() fails to clean up all the device state (ie received endpoint info). Signed-off-by: Hans de Goede (cherry picked from commit 5b3bd68244c87e161ea309ed380f216acf7cd754) --- usb-redir.c | 11 +++++++---- 1 files changed, 7 insertions(+), 4 deletions(-) Signed-off-by: Michal Novotny --- usb-redir.c | 11 +++++++---- 1 files changed, 7 insertions(+), 4 deletions(-) diff --git a/usb-redir.c b/usb-redir.c index a8daf31..d369bb3 100644 --- a/usb-redir.c +++ b/usb-redir.c @@ -980,7 +980,7 @@ static int usbredir_check_filter(USBRedirDevice *dev) { if (dev->interface_info.interface_count == 0) { ERROR("No interface info for device\n"); - return -1; + goto error; } if (dev->filter_rules) { @@ -988,7 +988,7 @@ static int usbredir_check_filter(USBRedirDevice *dev) usb_redir_cap_connect_device_version)) { ERROR("Device filter specified and peer does not have the " "connect_device_version capability\n"); - return -1; + goto error; } if (usbredirfilter_check( @@ -1005,11 +1005,15 @@ static int usbredir_check_filter(USBRedirDevice *dev) dev->device_info.product_id, dev->device_info.device_version_bcd, 0) != 0) { - return -1; + goto error; } } return 0; + +error: + usbredir_device_disconnect(dev); + return -1; } /* @@ -1136,7 +1140,6 @@ static void usbredir_interface_info(void *priv, if (usbredir_check_filter(dev)) { ERROR("Device no longer matches filter after interface info " "change, disconnecting!\n"); - usbredir_device_disconnect(dev); } } } -- 1.7.7.6