diff options
author | Gerd Hoffmann | 2011-06-06 09:45:20 +0200 |
---|---|---|
committer | Gerd Hoffmann | 2011-06-14 12:56:49 +0200 |
commit | 1f45a81bef8bc4aee98e29bd28bfb21edb623879 (patch) | |
tree | ca43d39364c5319bac9a54f68661b2a610ce3eab /usb-linux.c | |
parent | usb-linux: Don't try to open the same device twice (diff) | |
download | qemu-1f45a81bef8bc4aee98e29bd28bfb21edb623879.tar.gz qemu-1f45a81bef8bc4aee98e29bd28bfb21edb623879.tar.xz qemu-1f45a81bef8bc4aee98e29bd28bfb21edb623879.zip |
usb-linux: only cleanup in host_close when host_open was successful.
Diffstat (limited to 'usb-linux.c')
-rw-r--r-- | usb-linux.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/usb-linux.c b/usb-linux.c index a1b14448e9..a4dfe5ca17 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; } |