qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 24/31] usb-linux: only cleanup in host_close when ho


From: Gerd Hoffmann
Subject: [Qemu-devel] [PATCH 24/31] usb-linux: only cleanup in host_close when host_open was successful.
Date: Mon, 6 Jun 2011 14:39:15 +0200

---
 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]