qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] xhci: fix segfault
@ 2013-07-31  9:10 Gerd Hoffmann
  2013-07-31 12:26 ` Laszlo Ersek
  0 siblings, 1 reply; 2+ messages in thread
From: Gerd Hoffmann @ 2013-07-31  9:10 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann, qemu-stable

Guest trying to reset a endpoint of a disconnected device resulted in
xhci trying to dereference uport while being NULL, thereby crashing
qemu.  Fix that by adding a check.  Drop unused dev variable while
touching that code bit.

Cc: qemu-stable@nongnu.org
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/usb/hcd-xhci.c |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
index a4cb13a..a922cb4 100644
--- a/hw/usb/hcd-xhci.c
+++ b/hw/usb/hcd-xhci.c
@@ -1443,7 +1443,6 @@ static TRBCCode xhci_reset_ep(XHCIState *xhci, unsigned int slotid,
 {
     XHCISlot *slot;
     XHCIEPContext *epctx;
-    USBDevice *dev;
 
     trace_usb_xhci_ep_reset(slotid, epid);
     assert(slotid >= 1 && slotid <= xhci->numslots);
@@ -1479,8 +1478,8 @@ static TRBCCode xhci_reset_ep(XHCIState *xhci, unsigned int slotid,
         ep |= 0x80;
     }
 
-    dev = xhci->slots[slotid-1].uport->dev;
-    if (!dev) {
+    if (!xhci->slots[slotid-1].uport ||
+        !xhci->slots[slotid-1].uport->dev) {
         return CC_USB_TRANSACTION_ERROR;
     }
 
-- 
1.7.9.7

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [PATCH] xhci: fix segfault
  2013-07-31  9:10 [Qemu-devel] [PATCH] xhci: fix segfault Gerd Hoffmann
@ 2013-07-31 12:26 ` Laszlo Ersek
  0 siblings, 0 replies; 2+ messages in thread
From: Laszlo Ersek @ 2013-07-31 12:26 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: qemu-devel, qemu-stable

On 07/31/13 11:10, Gerd Hoffmann wrote:
> Guest trying to reset a endpoint of a disconnected device resulted in
> xhci trying to dereference uport while being NULL, thereby crashing
> qemu.  Fix that by adding a check.  Drop unused dev variable while
> touching that code bit.
> 
> Cc: qemu-stable@nongnu.org
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
>  hw/usb/hcd-xhci.c |    5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
> index a4cb13a..a922cb4 100644
> --- a/hw/usb/hcd-xhci.c
> +++ b/hw/usb/hcd-xhci.c
> @@ -1443,7 +1443,6 @@ static TRBCCode xhci_reset_ep(XHCIState *xhci, unsigned int slotid,
>  {
>      XHCISlot *slot;
>      XHCIEPContext *epctx;
> -    USBDevice *dev;
>  
>      trace_usb_xhci_ep_reset(slotid, epid);
>      assert(slotid >= 1 && slotid <= xhci->numslots);
> @@ -1479,8 +1478,8 @@ static TRBCCode xhci_reset_ep(XHCIState *xhci, unsigned int slotid,
>          ep |= 0x80;
>      }
>  
> -    dev = xhci->slots[slotid-1].uport->dev;
> -    if (!dev) {
> +    if (!xhci->slots[slotid-1].uport ||
> +        !xhci->slots[slotid-1].uport->dev) {
>          return CC_USB_TRANSACTION_ERROR;
>      }
>  
> 

Reviewed-by: Laszlo Ersek <lersek@redhat.com>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-07-31 12:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-31  9:10 [Qemu-devel] [PATCH] xhci: fix segfault Gerd Hoffmann
2013-07-31 12:26 ` Laszlo Ersek

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