From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH 5/8] KVM: Add kvm_get_irq_routing_entry() func Date: Wed, 20 Oct 2010 11:32:48 +0200 Message-ID: <4CBEB740.3090101@redhat.com> References: <1287565999-30499-1-git-send-email-sheng@linux.intel.com> <1287566255-30747-1-git-send-email-sheng@linux.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Marcelo Tosatti , "Michael S. Tsirkin" , kvm@vger.kernel.org To: Sheng Yang Return-path: Received: from mx1.redhat.com ([209.132.183.28]:28789 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752000Ab0JTJcx (ORCPT ); Wed, 20 Oct 2010 05:32:53 -0400 In-Reply-To: <1287566255-30747-1-git-send-email-sheng@linux.intel.com> Sender: kvm-owner@vger.kernel.org List-ID: On 10/20/2010 11:17 AM, Sheng Yang wrote: > } > > +int kvm_get_irq_routing_entry(struct kvm *kvm, int gsi, > + struct kvm_kernel_irq_routing_entry *entry) > +{ > + int count = 0; > + struct kvm_kernel_irq_routing_entry *ei = NULL; > + struct kvm_irq_routing_table *irq_rt; > + struct hlist_node *n; > + > + rcu_read_lock(); > + irq_rt = rcu_dereference(kvm->irq_routing); > + if (gsi< irq_rt->nr_rt_entries) > + hlist_for_each_entry(ei, n,&irq_rt->map[gsi], link) > + count++; > + rcu_read_unlock(); > + if (count == 1) > + memcpy(entry, ei, sizeof(*ei)); Need to be before the unlock. > + > + return (count != 1); > +} > + "*entry = *ei" is clearer and safer. But is it correct? we might be using outdated data. -- error compiling committee.c: too many arguments to function