Patchwork usb_packet_complete assert(p->owner != NULL)

login
register
mail settings
Submitter Gerd Hoffmann
Date Oct. 10, 2011, 12:24 p.m.
Message ID <4E92E3F4.8040101@redhat.com>
Download mbox | patch
Permalink /patch/118726/
State New
Headers show

Comments

Gerd Hoffmann - Oct. 10, 2011, 12:24 p.m.
Hi,

> -    usb_packet_complete(&s->dev, packet);
> +    s->dev.port->ops->complete(s->dev.port, packet);
>   }

> The hub is now directly invoking .complete() and not messing with
> packet->owner (which is already NULL).  We don't hit the assertion
> anymore.

Does the attached patch work for you?

cheers,
   Gerd
From 192f6ed2d669c10d29e8f7f1f5682357fb0ce9c3 Mon Sep 17 00:00:00 2001
From: Gerd Hoffmann <kraxel@redhat.com>
Date: Mon, 10 Oct 2011 14:12:09 +0200
Subject: [PATCH] usb: fix packet owner tracking with hub

usb_packet_complete should only clear owner when called from the device
itself, not from a usb hub.  Complements the special case for the hub in
usb_handle_packet().

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

Patch

diff --git a/hw/usb.c b/hw/usb.c
index 0f163b4..0c2fe86 100644
--- a/hw/usb.c
+++ b/hw/usb.c
@@ -347,7 +347,9 @@  void usb_packet_complete(USBDevice *dev, USBPacket *p)
 {
     /* Note: p->owner != dev is possible in case dev is a hub */
     assert(p->owner != NULL);
-    p->owner = NULL;
+    if (p->owner == dev) {
+        p->owner = NULL;
+    }
     dev->port->ops->complete(dev->port, p);
 }