From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60714) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V9GHC-0005ux-UU for qemu-devel@nongnu.org; Tue, 13 Aug 2013 11:13:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V9GH4-0004AX-5X for qemu-devel@nongnu.org; Tue, 13 Aug 2013 11:12:50 -0400 Sender: fluxion From: Michael Roth Date: Tue, 13 Aug 2013 10:11:08 -0500 Message-Id: <1376406680-16302-45-git-send-email-mdroth@linux.vnet.ibm.com> In-Reply-To: <1376406680-16302-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1376406680-16302-1-git-send-email-mdroth@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 44/56] xhci: fix segfault List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: aliguori@us.ibm.com, qemu-stable@nongnu.org From: Gerd Hoffmann 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 (cherry picked from commit 75cc1c1fcba1987bdf3979c4289ab756c2b15742) Signed-off-by: Michael Roth --- 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 632ede8..d88c1ae 100644 --- a/hw/usb/hcd-xhci.c +++ b/hw/usb/hcd-xhci.c @@ -1395,7 +1395,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); @@ -1431,8 +1430,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.5