Received: by 10.192.165.148 with SMTP id m20csp775191imm; Fri, 27 Apr 2018 07:20:20 -0700 (PDT) X-Google-Smtp-Source: AB8JxZp+tiMCcmbM2goNZRnPPFPVbYVIhn9mvBUwy/h21yfWxlRBR6qFvZK3SQAYCFGJ0A2jxj0g X-Received: by 10.98.224.76 with SMTP id f73mr2433875pfh.88.1524838820866; Fri, 27 Apr 2018 07:20:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524838820; cv=none; d=google.com; s=arc-20160816; b=oVSLQFgJk+o9305bsqOT+nSC0n3QiIQe7QaM25l6NogMEa/NXAthcf09QPC5oLSO98 x9neJdd/Cio0eJFg8zhDRW4O5oZw6xRkqgZ12zSZaMn4BfFIuMZSOO6615gtlHEzBrOT G7OKws55xCSndMzSARVWwjPx7e8vt6fzDw8WZK5cNe3H3VqwrxtSXczGLx4x2CrrdrgT CLjQBj1NXA0LUFsxWedtg1TLTeEtZkM0To32ZY1MyeiCnv6VyfQI1rHzU54KyfuYN4L6 i9nBxYjfzBZTJ1V0D/xgRx1CMG85Dp35yptukDA7fsXeizY8bVBGCMCPi43qywyP7nRt KSLw== 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=sxG/wqr1avUidIJ3b1J2fITL3qJC/zkB+wt6Fw8/rp8HgmibRbuZbMlDt/Vjcw0mrj KkR4GybaVx1z236G/shYdWZgSmlQ3Wz8+l5oT/8nzzs6NyQe6xGjIJEBgIQF9gD8cHrt 2zXeaNNC4xoyj9ky5Bu/4AcmFofb/vEWq3Ifk/OffvSOlD/JjDZCmMx2H5ZI2KA//vjN f0XLNb2ZSd7BOLxWFlucJSUZ0tm1KVAjNoxwC0jtuGItk4tbiA8E+/CFiZn4OO1YylLf JI/0MCVNXvOBem2W9mrTrmmuRXUXdm/sVzvCZh1KImjj41xI4HVK2b4Z3V9No50u+LJN dNng== 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 o1-v6si1292294plk.577.2018.04.27.07.20.06; Fri, 27 Apr 2018 07:20:20 -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 S935436AbeD0OPX (ORCPT + 99 others); Fri, 27 Apr 2018 10:15:23 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:54522 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S935318AbeD0OPQ (ORCPT ); Fri, 27 Apr 2018 10:15:16 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 20806406EA4F; Fri, 27 Apr 2018 14:15:16 +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 71168AB3F0; Fri, 27 Apr 2018 14:15:14 +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 v4 01/12] KVM: arm/arm64: Set dist->spis to NULL after kfree Date: Fri, 27 Apr 2018 16:14:54 +0200 Message-Id: <1524838505-3823-2-git-send-email-eric.auger@redhat.com> In-Reply-To: <1524838505-3823-1-git-send-email-eric.auger@redhat.com> References: <1524838505-3823-1-git-send-email-eric.auger@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Fri, 27 Apr 2018 14:15:16 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Fri, 27 Apr 2018 14:15:16 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.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