Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp6430488ybc; Wed, 27 Nov 2019 22:40:25 -0800 (PST) X-Google-Smtp-Source: APXvYqyb0SBYkFbDCdaalqyBxwx6v7uLRBBGC3MVQ9BN4aOqmP6MsWHrcujST73OAla2Zvcti4Jv X-Received: by 2002:a50:b632:: with SMTP id b47mr36314344ede.289.1574923225698; Wed, 27 Nov 2019 22:40:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574923225; cv=none; d=google.com; s=arc-20160816; b=btZNLz4N+0eDBakJdqsFb2+Ki3NpN7WE4PXxSz2kL/pr7PsT78ikWFn7u0J+Y9j65x V5Hbu7/p5/DLqGx/6wVkm+oUe7Q0vM0Q6ved66mR4Z1p8/WHjVb6FwTURV5NYTP/UDeK eLCcj5Nj/dYSjYLXsfI3OnG0vjFPNmWdOV1QUkU77CEMdkptTT0c+WfD3XGTH/F1paeq r7okMRyAptni+HnLcK1mftas3DTWFso7Vq5hEK7w79IqxeZeH0AtfmogaqXq6iVkz8s9 EVN9hOVoD96jWVOaTRa+GsxeijfLLGjmqe4bL2Z7HnN+nBigJdLPbxOXVIb1sJCVgXTc YR0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=PCivqwryPlJMw/C9LGgho5ghBfulpzEiGLZ5UKjZHiM=; b=O3Ru2m3NQwfXGWqm0tlg1HPIgJ9qLPPsCefut0SwVJyued9gw1ordY8WfnmFKVvJ5D fdHLPIirNV8LdQz9ZAAXhrzg0RT6QtGsmWFOwl+ks3rOH+a0b/z9u4B/qLMeMdvcnvf+ JkadTN5WJld1Vmq90A7msYt6T71ZZTEdfK11lisnapLjpVM3+LDUIMRg8+pdRL0YhdRN dharwyXl6FdTWk+58cE7njx/LZ7eiyn62UDqwn7qAJHrPT1Km70UVbzuO26bTY2206qR N3td9mXf3VMFk6OyAffyqWRvHv16laQ4KxzIBe1kbMsE+v1M4prLBn6/rFC7ctG4eGcG NW/g== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l64si13496364edl.306.2019.11.27.22.40.01; Wed, 27 Nov 2019 22:40:25 -0800 (PST) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726715AbfK1Gi4 (ORCPT + 99 others); Thu, 28 Nov 2019 01:38:56 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:7173 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726301AbfK1Gi4 (ORCPT ); Thu, 28 Nov 2019 01:38:56 -0500 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 697B7D7E59EC32DF0DB2; Thu, 28 Nov 2019 14:38:53 +0800 (CST) Received: from huawei.com (10.175.105.18) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.439.0; Thu, 28 Nov 2019 14:38:45 +0800 From: linmiaohe To: , , , , , , , , , , , , CC: , , , , Subject: [PATCH] KVM: vgic: Fix potential double free dist->spis in __kvm_vgic_destroy() Date: Thu, 28 Nov 2019 14:38:48 +0800 Message-ID: <1574923128-19956-1-git-send-email-linmiaohe@huawei.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.105.18] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Miaohe Lin In kvm_vgic_dist_init() called from kvm_vgic_map_resources(), if dist->vgic_model is invalid, dist->spis will be freed without set dist->spis = NULL. And in vgicv2 resources clean up path, __kvm_vgic_destroy() will be called to free allocated resources. And dist->spis will be freed again in clean up chain because we forget to set dist->spis = NULL in kvm_vgic_dist_init() failed path. So double free would happen. Signed-off-by: Miaohe Lin --- 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 53e3969dfb52..c17c29beeb72 100644 --- a/virt/kvm/arm/vgic/vgic-init.c +++ b/virt/kvm/arm/vgic/vgic-init.c @@ -171,6 +171,7 @@ static int kvm_vgic_dist_init(struct kvm *kvm, unsigned int nr_spis) break; default: kfree(dist->spis); + dist->spis = NULL; return -EINVAL; } } -- 2.19.1