From patchwork Tue Jul 30 17:45:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 11066401 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6B5691395 for ; Tue, 30 Jul 2019 17:48:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5C3222888A for ; Tue, 30 Jul 2019 17:48:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5A387283AD; Tue, 30 Jul 2019 17:48:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4AB4E2887D for ; Tue, 30 Jul 2019 17:48:06 +0000 (UTC) Received: from localhost ([::1]:35361 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsWEH-0003sO-Hh for patchwork-qemu-devel@patchwork.kernel.org; Tue, 30 Jul 2019 13:48:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37638) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsWBY-0007OV-EH for qemu-devel@nongnu.org; Tue, 30 Jul 2019 13:45:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hsWBX-0004l9-E8 for qemu-devel@nongnu.org; Tue, 30 Jul 2019 13:45:16 -0400 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]:46554) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hsWBX-0004ki-6X for qemu-devel@nongnu.org; Tue, 30 Jul 2019 13:45:15 -0400 Received: by mail-pf1-x442.google.com with SMTP id c3so7078924pfa.13 for ; Tue, 30 Jul 2019 10:45:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id; bh=cvS6j7L4RGks6c/xdAxmA9aq+ZtT2dbcFIv9lTlHrU8=; b=FBH6G181bdVB9ee/nLHCKPAWuZPIvBf7h76ANEsqRY8pk+Pi7wnQNwiXyq/oCXL5L9 duLVzg7LbkX0FatgchOPgNxzrRx2qmXsweQw/6FBMRRTVm7Hk+huDcSkz4Yeg5bPi3eu kMDmfR2bbWIX2vg5Yx/46zEydFYzgu2gngH72QsmXAwVOMqsQquVcJX6qLKTC5/63Eji EbkjGJC1mA+DbQhFqRpqnLAgw+FjutMvlbgihxiIKKGhkv8hcHyIQeKSx7J2CHsCB1lS bdEf3cJIGiRjwZM6JFcC00gJblp7j+CWQaLJib2qGqG9Oylji7kIrZfb7HVPx+aABope vQeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=cvS6j7L4RGks6c/xdAxmA9aq+ZtT2dbcFIv9lTlHrU8=; b=L0Q2OBOt8nh7OhkatMFAPH1R56uj8+wd9hBntlPhtIihFCXLGI37FBm2LMaJk0Ipox ffNdahckXxuuWbbdXPXk4LtQdIRAOcGjhs8nTTucrOs7ipjEPMdWKIq7uEWFygWlriFa VZ8ElGeDd/iFKyB7qV8dp2VFpiSVz6QTV1zstxBLRUZ6No2cNWnry+fqeBxU08N3aFox KsVW3DYRBRsyDTlnb2aQaewn3lfnveL0DgJOFPqdVu2gj2oFLhiMTuCjwarN8gDD/XEJ cECcSd/vHsEfzw+pXB9hhj/oBBwtSETZq7ZdXfz1+embHZUJs3pdcW+HIhkjFAdiHgK5 PVMA== X-Gm-Message-State: APjAAAVb3en9z6n4jGGH6iy6mt2wplVr+DBH0hXJCSwMac/76TUH4mHY v6y5nf/rlor75rtGT+QyUdQ= X-Google-Smtp-Source: APXvYqwqdKeqOGyTv4mACkpUkpmyrFSOZAVFe879ObYUD9BmaUKhDRLjGK5cigAGMnLyjJhdJcHDXw== X-Received: by 2002:a17:90a:1d8:: with SMTP id 24mr120052444pjd.70.1564508713893; Tue, 30 Jul 2019 10:45:13 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id r13sm93613640pfr.25.2019.07.30.10.45.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Jul 2019 10:45:12 -0700 (PDT) From: Guenter Roeck To: Gerd Hoffmann Date: Tue, 30 Jul 2019 10:45:10 -0700 Message-Id: <1564508710-22909-1-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::442 Subject: [Qemu-devel] [PATCH] ehci: Ensure that device is not NULL before calling usb_ep_get X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , qemu-devel@nongnu.org, Guenter Roeck , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The following assert is seen once in a while while resetting the Linux kernel. qemu-system-x86_64: hw/usb/core.c:734: usb_ep_get: Assertion `dev != NULL' failed. The call to usb_ep_get() originates from ehci_execute(). Analysis and debugging shows that p->queue->dev can indeed be NULL in this function. Add check for this condition and return an error if it is seen. Signed-off-by: Guenter Roeck Reported-by: Guenter Roeck Signed-off-by: Gerd Hoffmann Tested-by: Guenter Roeck --- hw/usb/hcd-ehci.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c index 62dab05..c759f3e 100644 --- a/hw/usb/hcd-ehci.c +++ b/hw/usb/hcd-ehci.c @@ -1348,6 +1348,11 @@ static int ehci_execute(EHCIPacket *p, const char *action) return -1; } + if (p->queue->dev == NULL) { + ehci_trace_guest_bug(p->queue->ehci, "No device attached to queue\n"); + return -1; + } + if (get_field(p->qtd.token, QTD_TOKEN_TBYTES) > BUFF_SIZE) { ehci_trace_guest_bug(p->queue->ehci, "guest requested more bytes than allowed");