From patchwork Fri Oct 19 20:39:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liam Merwick X-Patchwork-Id: 10650163 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 F0F28112B for ; Fri, 19 Oct 2018 20:45:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E20F32843B for ; Fri, 19 Oct 2018 20:45:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D5B132844C; Fri, 19 Oct 2018 20:45:44 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 86F232843B for ; Fri, 19 Oct 2018 20:45:44 +0000 (UTC) Received: from localhost ([::1]:52677 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gDbeR-0004wr-9a for patchwork-qemu-devel@patchwork.kernel.org; Fri, 19 Oct 2018 16:45:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54843) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gDbY4-0007zb-FS for qemu-devel@nongnu.org; Fri, 19 Oct 2018 16:39:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gDbY3-0002ir-Sg for qemu-devel@nongnu.org; Fri, 19 Oct 2018 16:39:08 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:35414) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gDbXy-0002Z3-QZ; Fri, 19 Oct 2018 16:39:03 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w9JKYPbD095167; Fri, 19 Oct 2018 20:39:02 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=zo64GhLGJWFhCagT++WkRM5tMxEF++SaWiNegNlBcZQ=; b=KMnmSZ5Jakq2CrfMPNl8z7VSZE11cosHo4xe/zbmrX7sqZjfKCXffjI/ugkVmV8KkaP4 umnVYldLnh5v+VGBUBZEUvbjOhzTfHJSqlPG06oHI1x4dz+dsUY5gBoA+9xCzMDtC76I kK7zScaNrOkKP1dEh1iAOZL1aEax0ao7gOPZGvtMDrqp6J9kby35YAHUOobN7JZeH57D Ljre/0LNX6ZqjVC30x8v+xq2xLdbFt219UTRyrwszxM2YxpPd6VrYzr5al7wcb8rs43S +Bz3XxnnP7uc031puuvxqSTyd91P5tUf8VAkA+aSmLPjHaJBfx0wgIQzFrEhJ/AS3rmo nA== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2120.oracle.com with ESMTP id 2n39brwxp6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 19 Oct 2018 20:39:01 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w9JKd0V3024780 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 19 Oct 2018 20:39:01 GMT Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w9JKd0QY030817; Fri, 19 Oct 2018 20:39:00 GMT Received: from ol7.uk.oracle.com (/10.175.186.240) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 19 Oct 2018 13:38:59 -0700 From: Liam Merwick To: qemu-devel@nongnu.org Date: Fri, 19 Oct 2018 21:39:06 +0100 Message-Id: <1539981546-10596-9-git-send-email-Liam.Merwick@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1539981546-10596-1-git-send-email-Liam.Merwick@oracle.com> References: <1539981546-10596-1-git-send-email-Liam.Merwick@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9051 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=701 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810190183 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.85 Subject: [Qemu-devel] [PATCH v4 8/8] kvm: Potential NULL pointer dereference in kvm_arch_init_vcpu() 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: kwolf@redhat.com, jsnow@redhat.com, qemu-block@nongnu.org, mreitz@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP In kvm_arch_init_vcpu() a call to cpuid_find_entry() can return NULL so the pointer returned should be checked before dereferencing it. Signed-off-by: Liam Merwick --- target/i386/kvm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/target/i386/kvm.c b/target/i386/kvm.c index dc4047b02fc5..eb19c87a9d25 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -1177,7 +1177,9 @@ int kvm_arch_init_vcpu(CPUState *cs) c->ecx = c->edx = 0; c = cpuid_find_entry(&cpuid_data.cpuid, kvm_base, 0); - c->eax = MAX(c->eax, KVM_CPUID_SIGNATURE | 0x10); + if (c) { + c->eax = MAX(c->eax, KVM_CPUID_SIGNATURE | 0x10); + } } cpuid_data.cpuid.nent = cpuid_i;