Received: by 10.192.165.148 with SMTP id m20csp3558071imm; Mon, 30 Apr 2018 02:16:31 -0700 (PDT) X-Google-Smtp-Source: AB8JxZroW5Qe6Ae2gxJLyxqeB/fFHqA33phnEA2UvpDyI2QbsmiLjPC+zFQoYeHk+7xQRse3XuU3 X-Received: by 10.98.204.220 with SMTP id j89mr11470308pfk.182.1525079791091; Mon, 30 Apr 2018 02:16:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525079791; cv=none; d=google.com; s=arc-20160816; b=leLJTuf1/HgTFec8bvFnLsupq9AiMtarslb3V7mQSSMfC3jnz5PeRV6/dnS1rN7DoI GCaZjTZ1AplFpMeAue5AqLIj68VO2Enxz6DKYF7hIUZMb7fjn4o3Q/Js/EvduvGFV1OT jcuwQ1w/nzwjJGt1Iao6J8BqvH32mptdEnRc7OVdUYuQwzdcnYNJAEc13QvNw1Q2FCKh Evbv6FhUd5c0C8HsCpdzcxVr+yeqcfzMYgz7r1gc2AzHyIQF2vIc4Efy5zrlNKBVBz4G iWs3usJ4iGyWzICL2s9ncIVqDgoa6XnR2DtGq1qrxbgKkQCKcpG7lQskWknN+YkRK+nV CVkw== 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=k2TSUZPmWNfVCrrqQb+0l82J7cX8HG2/+aeNJp2Suvo=; b=wTkMH9pUvOaj1/6/17qRPG8fRcEkk5X5QIm9kzgJMhAYKCSO/R6WpzVQZJfux60zh2 VN2h0ZjDPNt9sfzVPdYG1Ee6/UIjwVfkGowhamvPTWTnBrLlhIFim/njf5pC/kqMIMW7 HkBNFSptgRRDlgAW/WQn0s3m1tFMNwKPo41dWtXjRQ3wpuWOggMF0GKOD27hVGaobD9N 2qP5g7EzI+yicuXCSvGpPPDWy+jR0gJr9A3KDOa4tTFvwj0jRVTZajf7S9swXkhfhpdT tiL+9HgrMVBSlvN1+L0b0qJClRIKI8Hr4ZL8tsdnHISX2hsViD6fjdMHnwqMJ06bdsv4 H1FA== 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 b23-v6si5930940pge.682.2018.04.30.02.16.17; Mon, 30 Apr 2018 02:16:31 -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 S1752809AbeD3JHx (ORCPT + 99 others); Mon, 30 Apr 2018 05:07:53 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:44900 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752532AbeD3JHv (ORCPT ); Mon, 30 Apr 2018 05:07:51 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4346684257; Mon, 30 Apr 2018 09:07:51 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-57.ams2.redhat.com [10.36.116.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id 932332024CA1; Mon, 30 Apr 2018 09:07:49 +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 v5 01/12] KVM: arm/arm64: Set dist->spis to NULL after kfree Date: Mon, 30 Apr 2018 11:07:33 +0200 Message-Id: <1525079264-25533-2-git-send-email-eric.auger@redhat.com> In-Reply-To: <1525079264-25533-1-git-send-email-eric.auger@redhat.com> References: <1525079264-25533-1-git-send-email-eric.auger@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Mon, 30 Apr 2018 09:07:51 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Mon, 30 Apr 2018 09:07:51 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.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 Reviewed-by: Christoffer Dall --- 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