From patchwork Wed Sep 10 16:53:31 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris J Arges X-Patchwork-Id: 4879261 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id CCCB59F32E for ; Wed, 10 Sep 2014 16:54:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9F6AB201C0 for ; Wed, 10 Sep 2014 16:54:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6AD04201BC for ; Wed, 10 Sep 2014 16:54:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751963AbaIJQyK (ORCPT ); Wed, 10 Sep 2014 12:54:10 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:46479 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751447AbaIJQyJ (ORCPT ); Wed, 10 Sep 2014 12:54:09 -0400 Received: from cpe-173-174-67-34.austin.res.rr.com ([173.174.67.34] helo=localhost.localdomain) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1XRl9i-0006ii-3V; Wed, 10 Sep 2014 16:54:06 +0000 From: Chris J Arges To: kvm@vger.kernel.org Cc: Chris J Arges , Gleb Natapov , Paolo Bonzini , linux-kernel@vger.kernel.org Subject: [PATCH] KVM: ioapic: add check for RTC_GSI Date: Wed, 10 Sep 2014 11:53:31 -0500 Message-Id: <1410368033-23628-1-git-send-email-chris.j.arges@canonical.com> X-Mailer: git-send-email 1.9.1 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-9.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP cppcheck found the following error: [ioapic.c:114]: (error) Array index -1 is out of bounds. If CONFIG_X86 is not defined, RTC_GSI == -1U which means that an out of bounds error could occur when accessing &ioapic->redirtbl[RTC_GSI]. This patch adds a check to kvm_rtc_eoi_tracking_restore_one that is similar to how kvm_rtc_eoi_tracking_restore_all checks this condition. Signed-off-by: Chris J Arges --- virt/kvm/ioapic.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/virt/kvm/ioapic.c b/virt/kvm/ioapic.c index e8ce34c..859f5b8 100644 --- a/virt/kvm/ioapic.c +++ b/virt/kvm/ioapic.c @@ -136,6 +136,9 @@ void kvm_rtc_eoi_tracking_restore_one(struct kvm_vcpu *vcpu) { struct kvm_ioapic *ioapic = vcpu->kvm->arch.vioapic; + if (RTC_GSI >= IOAPIC_NUM_PINS) + return; + spin_lock(&ioapic->lock); __rtc_irq_eoi_tracking_restore_one(vcpu); spin_unlock(&ioapic->lock);