From patchwork Tue Feb 28 10:20:26 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 143439 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 662A9B6EEC for ; Tue, 28 Feb 2012 23:04:48 +1100 (EST) Received: from localhost ([::1]:37253 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S2KBN-00086E-ME for incoming@patchwork.ozlabs.org; Tue, 28 Feb 2012 05:21:21 -0500 Received: from eggs.gnu.org ([208.118.235.92]:34287) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S2KAv-00073j-Ms for qemu-devel@nongnu.org; Tue, 28 Feb 2012 05:20:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S2KAo-00043S-1e for qemu-devel@nongnu.org; Tue, 28 Feb 2012 05:20:53 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52175) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S2KAn-00042V-Qv for qemu-devel@nongnu.org; Tue, 28 Feb 2012 05:20:45 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q1SAKiCo027087 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 28 Feb 2012 05:20:44 -0500 Received: from rincewind.home.kraxel.org (ovpn-116-50.ams2.redhat.com [10.36.116.50]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q1SAKdTJ005440; Tue, 28 Feb 2012 05:20:42 -0500 Received: by rincewind.home.kraxel.org (Postfix, from userid 500) id 9EF2541330; Tue, 28 Feb 2012 11:20:31 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Tue, 28 Feb 2012 11:20:26 +0100 Message-Id: <1330424430-23015-18-git-send-email-kraxel@redhat.com> In-Reply-To: <1330424430-23015-1-git-send-email-kraxel@redhat.com> References: <1330424430-23015-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: Hans de Goede , Gerd Hoffmann Subject: [Qemu-devel] [PATCH 17/21] usb-redir: Always clear device state on filter reject X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Hans de Goede 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 Signed-off-by: Gerd Hoffmann --- usb-redir.c | 11 +++++++---- 1 files changed, 7 insertions(+), 4 deletions(-) diff --git a/usb-redir.c b/usb-redir.c index 18204be..c98b14e 100644 --- a/usb-redir.c +++ b/usb-redir.c @@ -958,7 +958,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) { @@ -966,7 +966,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( @@ -983,11 +983,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; } /* @@ -1113,7 +1117,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); } } }