Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1952847pxu; Sun, 13 Dec 2020 08:38:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJyUUf4XfpTZ9U+3ZOfCOXglkW7jDrVWXkW5ieIdb5p9FSaqv5DW8lgVu2MynrS6HgBgeDqv X-Received: by 2002:aa7:cf8f:: with SMTP id z15mr21265507edx.17.1607877487910; Sun, 13 Dec 2020 08:38:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607877487; cv=none; d=google.com; s=arc-20160816; b=Ms61ImtRCX+9+80gZHzDe8NXE0KTuJNHcTthfV2YaPt+tn8ygafxN7N9zl8WYSCu0T DqETc6g7Ep+4iBDOvzKoE5LUDFjLQAQiMrX2seeLGvklTfJUQ2BVNx71WO49nUQZKcJD 9fVnsC43bdZBFjsbWYN4DkdI31qNOdD9iEYWc2eRvTxLACOFYDCBMZ0+WwrrDgH1Zpd6 jPNAJMkinAwNyYT6b0L45VpDd6/zA0OExrEBXmU1rWjAzCqf9gtBDARxj8FP18Kuj7k+ Xe4GBb/tmPbAOiGZz32n2oIOqCzwuaGyR73fUbUeAGcJBRQRtwB6XBhuO1qzgh8f2Hsn ANcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=1BdGsydJTiQm/M6xJTXUVfv5CezsJI9l7viP4YuCYYo=; b=vusVxQiUSPCMdl+h8CjNgYDScFLyQQUwoYeJLMWdaILxCxUkACnEMtv9tn9sPSUNUw sdq7wVh4pI1b4ThfbdGgrPs5OaCAnMMDM+JtTwTmwq9oBZaSrD5L9TL9QiSdPqiMpHLh tca+fMTpbZ6iWbA/+GzFCQEAjINMm9qSx0zap+oUO1U9uYGzUweo6EseHZQKdzicRHiD GHwFx/tyLi1KijPvwVCfVvUkC3OyMRvGINFfhU258pCpZK9QCrMo4bfk3gmQvyuC3R3Z Q0Yc2dMQmnML9JPXGExBqA/3b3OXYZNZcfvksC5Q7/G5yed4Z9ik3J4a6s3f0f6ZkF4R ePJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=eexJv39M; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h12si8342177eje.122.2020.12.13.08.37.45; Sun, 13 Dec 2020 08:38:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=eexJv39M; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2437845AbgLLSwb (ORCPT + 99 others); Sat, 12 Dec 2020 13:52:31 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:35378 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2407746AbgLLSwH (ORCPT ); Sat, 12 Dec 2020 13:52:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1607799040; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1BdGsydJTiQm/M6xJTXUVfv5CezsJI9l7viP4YuCYYo=; b=eexJv39MwFBC2DmejzF2qPGedd90BWO4kkykm2dmbYZtDyNHtU1xAh65c5AgwDIL30BLq9 tBd9zXEeAyj4k1c/4F4kffmAkmAGx2ypc0eCLFzOYwZM1zgG7vwa+E0Dp4UeVjX1ZIT6AH ZeVk8uIKlVLlD0aX0/YZ9D8JLApv+VA= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-120-5mjWVj-oMSOIO5Qmv8Os0w-1; Sat, 12 Dec 2020 13:50:37 -0500 X-MC-Unique: 5mjWVj-oMSOIO5Qmv8Os0w-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 936C3180A087; Sat, 12 Dec 2020 18:50:35 +0000 (UTC) Received: from laptop.redhat.com (ovpn-115-41.ams2.redhat.com [10.36.115.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id BA1FB1F45B; Sat, 12 Dec 2020 18:50:32 +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, maz@kernel.org, drjones@redhat.com Cc: alexandru.elisei@arm.com, james.morse@arm.com, julien.thierry.kdev@gmail.com, suzuki.poulose@arm.com, shuah@kernel.org, pbonzini@redhat.com Subject: [PATCH 3/9] KVM: arm64: vgic-v3: Fix error handling in vgic_v3_set_redist_base() Date: Sat, 12 Dec 2020 19:50:04 +0100 Message-Id: <20201212185010.26579-4-eric.auger@redhat.com> In-Reply-To: <20201212185010.26579-1-eric.auger@redhat.com> References: <20201212185010.26579-1-eric.auger@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org vgic_register_all_redist_iodevs may succeed while vgic_register_all_redist_iodevs fails. For example this can happen while adding a redistributor region overlapping a dist region. The failure only is detected on vgic_register_all_redist_iodevs when vgic_v3_check_base() gets called. In such a case, remove the newly added redistributor region and free it. Signed-off-by: Eric Auger --- arch/arm64/kvm/vgic/vgic-mmio-v3.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kvm/vgic/vgic-mmio-v3.c b/arch/arm64/kvm/vgic/vgic-mmio-v3.c index 8e8a862def76..581f0f490000 100644 --- a/arch/arm64/kvm/vgic/vgic-mmio-v3.c +++ b/arch/arm64/kvm/vgic/vgic-mmio-v3.c @@ -866,8 +866,14 @@ int vgic_v3_set_redist_base(struct kvm *kvm, u32 index, u64 addr, u32 count) * afterwards will register the iodevs when needed. */ ret = vgic_register_all_redist_iodevs(kvm); - if (ret) + if (ret) { + struct vgic_redist_region *rdreg = + vgic_v3_rdist_region_from_index(kvm, index); + + list_del(&rdreg->list); + kfree(rdreg); return ret; + } return 0; } -- 2.21.3