From patchwork Sun Oct 18 01:47:23 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 54585 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n9I1ls57019633 for ; Sun, 18 Oct 2009 01:47:54 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754125AbZJRBrp (ORCPT ); Sat, 17 Oct 2009 21:47:45 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754117AbZJRBrp (ORCPT ); Sat, 17 Oct 2009 21:47:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51917 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754037AbZJRBro (ORCPT ); Sat, 17 Oct 2009 21:47:44 -0400 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n9I1lmm6030790; Sat, 17 Oct 2009 21:47:48 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n9I1ll0k021182; Sat, 17 Oct 2009 21:47:48 -0400 Received: from amt.cnet (vpn-10-1.str.redhat.com [10.32.10.1]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n9I1ljFE018973; Sat, 17 Oct 2009 21:47:46 -0400 Received: from amt.cnet (amt.cnet [127.0.0.1]) by amt.cnet (Postfix) with ESMTP id 8E80558816E; Sat, 17 Oct 2009 22:47:25 -0300 (BRT) Received: (from marcelo@localhost) by amt.cnet (8.14.3/8.14.3/Submit) id n9I1lNEx016232; Sat, 17 Oct 2009 22:47:23 -0300 Date: Sat, 17 Oct 2009 22:47:23 -0300 From: Marcelo Tosatti To: kvm Cc: "Xu, Jiajun" Subject: KVM: fix irq_source_id size verification Message-ID: <20091018014723.GA16174@amt.cnet> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.19 (2009-01-05) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org diff --git a/virt/kvm/irq_comm.c b/virt/kvm/irq_comm.c index 00c68d2..0d454d3 100644 --- a/virt/kvm/irq_comm.c +++ b/virt/kvm/irq_comm.c @@ -215,10 +215,9 @@ int kvm_request_irq_source_id(struct kvm *kvm) int irq_source_id; mutex_lock(&kvm->irq_lock); - irq_source_id = find_first_zero_bit(bitmap, - sizeof(kvm->arch.irq_sources_bitmap)); + irq_source_id = find_first_zero_bit(bitmap, BITS_PER_LONG); - if (irq_source_id >= sizeof(kvm->arch.irq_sources_bitmap)) { + if (irq_source_id >= BITS_PER_LONG) { printk(KERN_WARNING "kvm: exhaust allocatable IRQ sources!\n"); irq_source_id = -EFAULT; goto unlock; @@ -240,7 +239,7 @@ void kvm_free_irq_source_id(struct kvm *kvm, int irq_source_id) mutex_lock(&kvm->irq_lock); if (irq_source_id < 0 || - irq_source_id >= sizeof(kvm->arch.irq_sources_bitmap)) { + irq_source_id >= BITS_PER_LONG) { printk(KERN_ERR "kvm: IRQ source ID out of range!\n"); goto unlock; }