Received: by 10.192.165.156 with SMTP id m28csp428110imm; Fri, 13 Apr 2018 01:28:08 -0700 (PDT) X-Google-Smtp-Source: AIpwx48Ob6NhRV8EYRgLLdmfAzfs6mXTzbTexocc4znzIV04fzuIe1H/QFXHQxk5DqUq3sjzdm4U X-Received: by 10.98.178.207 with SMTP id z76mr10733831pfl.37.1523608088524; Fri, 13 Apr 2018 01:28:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523608088; cv=none; d=google.com; s=arc-20160816; b=Um7HTerre4SihFR4dRzhathHcOZn06pksd8gt9jzUiXAYJUtkIDHS+neJw0KTZ2+m5 jraErJMqVleNSB/2so/FHi3t+JbcKZko4uiZeqyR0GaFOSVK6raJyq1Lb409ewgClxhL X1rWHLrti3UrPU0TgR9fAI20M+mReOL6MG4tFIRWxvb9u1qFR/SIkxGUFGvWY6Fx5GZ9 Th6IUySmq/KPhHQPg2tczdUnGUtnhHRNu2nFITuXAigzbIIqmLW8aE+R2ONPn20okQFK hFx3Oi4gI6H0RqlOFqRgYiV83QtfT0OY/G5rhqJ/xO9DdS6xgNYmhkj9pEpej+cMVL/X ANxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=1BjAnEwo3DcwmLXZU7sporVbbtwGR7Mjxk/EEDWVrRg=; b=yndzfSD9XoOe9IdTzTr4keDLyEJFwJvJjQz/Z/i9sI9A7UC9wscr2Z+wjrO8gtJxci Ro+1No8nvGLnNOxyWM289tSAQo/BPqBRYhQWRImpNs/+9Ov7PDl7sAPNlj+pxJXRtUgt Y3GWA8i+hfpPFTFSYg842ASmgxtPmlbWlJx6j4G8970lV/bzIHlQ1s26D+ZfBUy50MBF 5S8J5NrM9BRDd9MpUbqiTxD9YaGieBuNVsrZ6KuApieEQck4u+HPmYKTp2ujobRtSut3 4eF5tNK8lTT/yNiL3SgmeO7YzR21jal85b9R5WKi07pPzwQEG8IIZqnkfzzw5cBA6NJP oBlQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y6si1624266pgv.520.2018.04.13.01.27.54; Fri, 13 Apr 2018 01:28:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754097AbeDMI0K (ORCPT + 99 others); Fri, 13 Apr 2018 04:26:10 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:54038 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752512AbeDMIVF (ORCPT ); Fri, 13 Apr 2018 04:21:05 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2F39B9BA4B; Fri, 13 Apr 2018 08:21:05 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-192.ams2.redhat.com [10.36.116.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2EE5C215CDCF; Fri, 13 Apr 2018 08:21:03 +0000 (UTC) From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu, marc.zyngier@arm.com, cdall@kernel.org, peter.maydell@linaro.org Cc: andre.przywara@arm.com, drjones@redhat.com, wei@redhat.com Subject: [PATCH v3 01/12] KVM: arm/arm64: Set dist->spis to NULL after kfree Date: Fri, 13 Apr 2018 10:20:47 +0200 Message-Id: <1523607658-9166-2-git-send-email-eric.auger@redhat.com> In-Reply-To: <1523607658-9166-1-git-send-email-eric.auger@redhat.com> References: <1523607658-9166-1-git-send-email-eric.auger@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Fri, 13 Apr 2018 08:21:05 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Fri, 13 Apr 2018 08:21:05 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'eric.auger@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org in case kvm_vgic_map_resources() fails, typically if the vgic distributor is not defined, __kvm_vgic_destroy will be called several times. Indeed kvm_vgic_map_resources() is called on first vcpu run. As a result dist->spis is freeed more than once and on the second time it causes a "kernel BUG at mm/slub.c:3912!" Set dist->spis to NULL to avoid the crash. Fixes: ad275b8bb1e6 ("KVM: arm/arm64: vgic-new: vgic_init: implement vgic_init") Signed-off-by: Eric Auger Reviewed-by: Marc Zyngier --- v2 -> v3: - added Marc's R-b and Fixed commit --- virt/kvm/arm/vgic/vgic-init.c | 1 + 1 file changed, 1 insertion(+) diff --git a/virt/kvm/arm/vgic/vgic-init.c b/virt/kvm/arm/vgic/vgic-init.c index 68378fe..c52f03d 100644 --- a/virt/kvm/arm/vgic/vgic-init.c +++ b/virt/kvm/arm/vgic/vgic-init.c @@ -308,6 +308,7 @@ static void kvm_vgic_dist_destroy(struct kvm *kvm) dist->initialized = false; kfree(dist->spis); + dist->spis = NULL; dist->nr_spis = 0; if (vgic_supports_direct_msis(kvm)) -- 2.5.5