From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36121) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V4VSF-0005VP-BP for qemu-devel@nongnu.org; Wed, 31 Jul 2013 08:24:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V4VSA-0005kL-80 for qemu-devel@nongnu.org; Wed, 31 Jul 2013 08:24:35 -0400 Message-ID: <51F9028F.4080103@redhat.com> Date: Wed, 31 Jul 2013 14:26:55 +0200 From: Laszlo Ersek MIME-Version: 1.0 References: <1375261843-27585-1-git-send-email-kraxel@redhat.com> In-Reply-To: <1375261843-27585-1-git-send-email-kraxel@redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] xhci: fix segfault List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gerd Hoffmann Cc: qemu-devel@nongnu.org, qemu-stable@nongnu.org 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 > --- > 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