From 1f45a81bef8bc4aee98e29bd28bfb21edb623879 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Mon, 6 Jun 2011 09:45:20 +0200 Subject: [PATCH] usb-linux: only cleanup in host_close when host_open was successful. --- usb-linux.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/usb-linux.c b/usb-linux.c index a1b1444..a4dfe5c 100644 --- a/usb-linux.c +++ b/usb-linux.c @@ -1158,9 +1158,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; } @@ -1169,7 +1169,7 @@ static int usb_host_close(USBHostDevice *dev) { int i; - if (dev->fd == -1) { + if (dev->fd == -1 || !dev->dev.attached) { return -1; } -- 2.7.4