Message ID | 1340201134-21109-7-git-send-email-kraxel@redhat.com |
---|---|
State | New |
Headers | show |
>>> On 6/20/2012 at 08:05 AM, Gerd Hoffmann <kraxel@redhat.com> wrote: > We update the QTAILQ in the loop, thus we must use the SAFE version > to make sure we don't touch the queue struct after freeing it. > > https://bugzilla.novell.com/show_bug.cgi?id=766310 > > Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> > --- > hw/usb/hcd-uhci.c | 4 ++-- > 1 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c > index 9871e24..2ebce04 100644 > --- a/hw/usb/hcd-uhci.c > +++ b/hw/usb/hcd-uhci.c > @@ -292,10 +292,10 @@ static void uhci_async_cancel_device(UHCIState *s, > USBDevice *dev) > > static void uhci_async_cancel_all(UHCIState *s) > { > - UHCIQueue *queue; > + UHCIQueue *queue, *nq; > UHCIAsync *curr, *n; > > - QTAILQ_FOREACH(queue, &s->queues, next) { > + QTAILQ_FOREACH_SAFE(queue, &s->queues, next, nq) { > QTAILQ_FOREACH_SAFE(curr, &queue->asyncs, next, n) { > uhci_async_unlink(curr); > uhci_async_cancel(curr); This would also be good to include in next 1.1 stable release. Bruce
diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c index 9871e24..2ebce04 100644 --- a/hw/usb/hcd-uhci.c +++ b/hw/usb/hcd-uhci.c @@ -292,10 +292,10 @@ static void uhci_async_cancel_device(UHCIState *s, USBDevice *dev) static void uhci_async_cancel_all(UHCIState *s) { - UHCIQueue *queue; + UHCIQueue *queue, *nq; UHCIAsync *curr, *n; - QTAILQ_FOREACH(queue, &s->queues, next) { + QTAILQ_FOREACH_SAFE(queue, &s->queues, next, nq) { QTAILQ_FOREACH_SAFE(curr, &queue->asyncs, next, n) { uhci_async_unlink(curr); uhci_async_cancel(curr);
We update the QTAILQ in the loop, thus we must use the SAFE version to make sure we don't touch the queue struct after freeing it. https://bugzilla.novell.com/show_bug.cgi?id=766310 Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> --- hw/usb/hcd-uhci.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)