Received: from eggs.gnu.org ([140.186.70.92]:44786) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QTZ6Z-0008OR-VO for qemu-devel@nongnu.org; Mon, 06 Jun 2011 08:40:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QTZ6Y-0005aW-6w for qemu-devel@nongnu.org; Mon, 06 Jun 2011 08:40:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:21108) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QTZ6X-0005aF-Ko for qemu-devel@nongnu.org; Mon, 06 Jun 2011 08:40:25 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p56CeOX7013847 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 6 Jun 2011 08:40:24 -0400 From: Gerd Hoffmann Date: Mon, 6 Jun 2011 14:39:15 +0200 Message-Id: <1307363962-27223-25-git-send-email-kraxel@redhat.com> In-Reply-To: <1307363962-27223-1-git-send-email-kraxel@redhat.com> References: <1307363962-27223-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PATCH 24/31] usb-linux: only cleanup in host_close when host_open was successful. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gerd Hoffmann --- usb-linux.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/usb-linux.c b/usb-linux.c index 1208a97..be667f0 100644 --- a/usb-linux.c +++ b/usb-linux.c @@ -1159,9 +1159,9 @@ static int usb_host_open(USBHostDevice *dev, int bus_num, return 0; fail: - dev->fd = -1; - if (fd != -1) { - close(fd); + if (dev->fd != -1) { + close(dev->fd); + dev->fd = -1; } return -1; } @@ -1170,7 +1170,7 @@ static int usb_host_close(USBHostDevice *dev) { int i; - if (dev->fd == -1) { + if (dev->fd == -1 || !dev->dev.attached) { return -1; } -- 1.7.1