qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PATCH 3/3] usb-host: fix host close
Date: Tue,  1 Nov 2011 15:56:30 +0100	[thread overview]
Message-ID: <1320159390-29797-4-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1320159390-29797-1-git-send-email-kraxel@redhat.com>

The whole usb_host_close() function is skipped in case the device is not
in attached state.  This is wrong though, only then usb_device_detach()
must be skipped, all other cleanup (especially device reset and closing
the file handle) still needs to be done.  There are code paths where
usb_host_close() is called with the device in detached state already.

This fixes usb-host devices not being released and returned to the host
after removing them with device_del.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 usb-linux.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/usb-linux.c b/usb-linux.c
index 7d4d1d7..f086d57 100644
--- a/usb-linux.c
+++ b/usb-linux.c
@@ -1349,7 +1349,7 @@ static int usb_host_close(USBHostDevice *dev)
 {
     int i;
 
-    if (dev->fd == -1 || !dev->dev.attached) {
+    if (dev->fd == -1) {
         return -1;
     }
 
@@ -1367,7 +1367,9 @@ static int usb_host_close(USBHostDevice *dev)
     }
     async_complete(dev);
     dev->closing = 0;
-    usb_device_detach(&dev->dev);
+    if (dev->dev.attached) {
+        usb_device_detach(&dev->dev);
+    }
     ioctl(dev->fd, USBDEVFS_RESET);
     close(dev->fd);
     dev->fd = -1;
-- 
1.7.1

  parent reply	other threads:[~2011-11-01 14:56 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-01 14:56 [Qemu-devel] [PULL] usb patch queue Gerd Hoffmann
2011-11-01 14:56 ` [Qemu-devel] [PATCH 1/3] usb-hub: wakeup on attach Gerd Hoffmann
2011-11-02  9:38   ` hkran
2011-11-02 12:56     ` Gerd Hoffmann
2011-11-03  6:01       ` hkran
2011-11-03  8:41         ` Gerd Hoffmann
2011-11-03  9:20           ` hkran
2011-11-10  3:45   ` hkran
2011-11-22 12:23     ` Gerd Hoffmann
2011-11-01 14:56 ` [Qemu-devel] [PATCH 2/3] usb: change VID/PID for usb-hub and usb-msd to prevent conflict Gerd Hoffmann
2011-11-01 15:29   ` Andreas Färber
2011-11-01 15:40     ` Gerd Hoffmann
2011-11-01 14:56 ` Gerd Hoffmann [this message]
2011-11-01 18:13 ` [Qemu-devel] [PULL] usb patch queue Anthony Liguori

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1320159390-29797-4-git-send-email-kraxel@redhat.com \
    --to=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).