From patchwork Wed Feb 6 13:36:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liam Merwick X-Patchwork-Id: 10799417 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 E46471390 for ; Wed, 6 Feb 2019 13:41:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CFE502AA67 for ; Wed, 6 Feb 2019 13:41:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CE6BB2AB07; Wed, 6 Feb 2019 13:41:34 +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=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id AAB3E2AAB4 for ; Wed, 6 Feb 2019 13:41:33 +0000 (UTC) Received: from localhost ([127.0.0.1]:51161 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1grNSH-00006j-0S for patchwork-qemu-devel@patchwork.kernel.org; Wed, 06 Feb 2019 08:41:33 -0500 Received: from eggs.gnu.org ([209.51.188.92]:58651) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1grNOY-0005Ju-AV for qemu-devel@nongnu.org; Wed, 06 Feb 2019 08:37:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1grNOT-0003pc-Jf for qemu-devel@nongnu.org; Wed, 06 Feb 2019 08:37:41 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:36392) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1grNOM-0003n1-2k for qemu-devel@nongnu.org; Wed, 06 Feb 2019 08:37:33 -0500 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x16DStZb155844; Wed, 6 Feb 2019 13:37:20 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2018-07-02; bh=V0RYFo899M+FNTzloOapiTQH2u1qfsJZWH7cMZgmxIw=; b=bu/HjUKHGNjZ6qD2oCSnzPTFIODDZPx2qTizLOlEf4Iz5jEnSY4EArJsCbHR4a0rDVbJ pgPj/WaSP5x7LfYfQMn01DUQyHV84mkpArzavi0/5jKWIPBoezu055ZLW3WsJM/PU/Z/ bTskIVoee735uJp5B+I6S5JtpEcBA0BLyOZ4dn4vusB2GzSEEKzIR0tUhSzGkSMGtqGv wPqR4/JLSnm5nRb6zJGocpw31O5Gz3VtMqxoiWPDQPvKB7NjOxTaHly8hXLfQuq5auMB kKPTWOsUiifCH7nZ5Zw7+TbTIvWz7UxRhxA8c+e303LvzOziBBgomdIux8LhCYQNq/D+ WA== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2120.oracle.com with ESMTP id 2qd98n906j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 06 Feb 2019 13:37:19 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id x16DbJtN013479 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 6 Feb 2019 13:37:19 GMT Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x16DbJS5004697; Wed, 6 Feb 2019 13:37:19 GMT Received: from ol7.nl.oracle.com (/10.175.12.46) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 06 Feb 2019 05:37:18 -0800 From: Liam Merwick To: kraxel@redhat.com, qemu-devel@nongnu.org Date: Wed, 6 Feb 2019 13:36:55 +0000 Message-Id: <1549460216-25808-9-git-send-email-liam.merwick@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1549460216-25808-1-git-send-email-liam.merwick@oracle.com> References: <1549460216-25808-1-git-send-email-liam.merwick@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9158 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=969 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1902060107 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.85 Subject: [Qemu-devel] [PATCH v2 8/9] usb: add device checks before redirector calls to usb_ep_get() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: darren.kenny@oracle.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Add an assert and an explicit check before the two callers to usb_ep_get() in the USB redirector code to ensure the device passed in is not NULL. Signed-off-by: Liam Merwick --- hw/usb/redirect.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c index 18a42d19380e..7cb6b120d4f0 100644 --- a/hw/usb/redirect.c +++ b/hw/usb/redirect.c @@ -1728,6 +1728,7 @@ static void usbredir_ep_info(void *priv, USBRedirDevice *dev = priv; int i; + assert(dev != NULL); for (i = 0; i < MAX_ENDPOINTS; i++) { dev->endpoint[i].type = ep_info->type[i]; dev->endpoint[i].interval = ep_info->interval[i]; @@ -2125,7 +2126,7 @@ static int usbredir_post_load(void *priv, int version_id) { USBRedirDevice *dev = priv; - if (dev->parser == NULL) { + if (dev == NULL || dev->parser == NULL) { return 0; }