From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759887AbdACRZW (ORCPT ); Tue, 3 Jan 2017 12:25:22 -0500 Received: from mx1.redhat.com ([209.132.183.28]:57464 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753090AbdACRZK (ORCPT ); Tue, 3 Jan 2017 12:25:10 -0500 Subject: Re: [PATCH] KVM: ioapic: fix NULL deref ioapic->lock To: David Hildenbrand , Wanpeng Li , Dmitry Vyukov References: <1483242289-12323-1-git-send-email-wanpeng.li@hotmail.com> Cc: LKML , KVM list , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , Wanpeng Li From: Paolo Bonzini Message-ID: <3f0b0708-0dda-85d4-a0a0-2d532d46db18@redhat.com> Date: Tue, 3 Jan 2017 18:23:06 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 03 Jan 2017 17:23:10 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/01/2017 13:06, David Hildenbrand wrote: >> >> switch (cap->cap) { >> case KVM_CAP_HYPERV_SYNIC: >> - return kvm_hv_activate_synic(vcpu); >> + if (!irqchip_in_kernel(vcpu->kvm)) >> + return -EINVAL; >> + else > > You can simply drop the else and return directly. > > Can't really say if this is the right fix, my first thought was that > a request has been set although it should never have been set for > that VCPU. Maybe that is an effect of synic being activated > (because synic code unconditionally later on sets the request). > > Fixing the cause of the request seems better than fixing up the result. Yes, I agree. Wanpeng's second patch is fine. Paolo