Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp2688243pxf; Sun, 4 Apr 2021 10:23:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx9CxFJ7zvg0UK8jKg3i1jojFqVpPF0BZU401Rk2zJtClVV10VsOnJSfTf9yQj2u0BWJGyC X-Received: by 2002:a05:6638:d47:: with SMTP id d7mr20692255jak.2.1617557029686; Sun, 04 Apr 2021 10:23:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617557029; cv=none; d=google.com; s=arc-20160816; b=RvemFPgrofWhLVpT2HOwWYzs26AdOy2fhXjKUc5x+H1DAdhgkOWdYDB6AsxBnrDsFL pWNwtNZpa5S+bDPuODrCpA/5vN+FlQm11mAFhcvLDd+hBjPZkgrvVGxKdpB96moiSWtL Se7u3qXke7nTvxcychMoWmTZ9HSeL9PijBu7P7CwEtSAsBadraDfx8+VyD1OBMscrQDJ VHH5KacumbKyx1LV8shN3FpZ0jyo7n8tIVg5IaVLSNvf8B5q2X5Ik8HZ64bigaOaEIGI piDcrO25x1aOS76OZRTzqA9xzjNg2cAF5FDX+wFQogZvsbg75lMqtnf2jd9jq10KkPX0 wZCw== 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=sEFChuAVCf9U3ksntSEVq3EEZP4wMNr2xt1gXOCeheg=; b=SAk+hfy5yzD0LKiyJ683aqv3oATWI5u6U1PMDqDPNWUCkvstNbrEPXJLbpScXCM95v 0Mu25ODI5wBYGhQtxMRDVK/+oxh6clZ3L3DKiH6RQEhJK7uN5VEQ/cMkqskH79BSs104 k/B2ISdaE/qm4ehjlZsgF0tBvnP3VirXZNTXvYf8ZVZ2xpDjhgkqxVYt7PUEGzDsmuW+ XXp0Ghb/JVdcRfX6W2LgOjcORadF77xV3q80ZmPsyyWMrKkL0P+CuN/SbEzKfHOFNxHa rKFOqjWRtE5XZIH7R85zubZa09yYKnx0AdOJ8N/yJ5cfkvHVn2MOnXLeiFFWFaJG/Irq OBLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=c3LswfWc; 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 v5si12183944ilo.128.2021.04.04.10.23.35; Sun, 04 Apr 2021 10:23:49 -0700 (PDT) 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=c3LswfWc; 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 S231326AbhDDRXM (ORCPT + 99 others); Sun, 4 Apr 2021 13:23:12 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:37601 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231303AbhDDRXG (ORCPT ); Sun, 4 Apr 2021 13:23:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617556981; 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=sEFChuAVCf9U3ksntSEVq3EEZP4wMNr2xt1gXOCeheg=; b=c3LswfWcq5XkxheR9VY8Qe9NIYzSmOB88iPPl8MC7VQh0B5z1cnzu8h7eNOuvsSOXpABLD dYYCoOLmofmj/86ivn53VBnDH1Q/Un0tqMjD9YczlZfcEwIbTvK62kJNEXQ/wwJj879EPs q9BMcD0URYjjkS0u14wzhO6h+hakJJ8= 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-277-ILd6NC2wPaKEScSDD53Wag-1; Sun, 04 Apr 2021 13:22:59 -0400 X-MC-Unique: ILd6NC2wPaKEScSDD53Wag-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EE4B984B9A0; Sun, 4 Apr 2021 17:22:57 +0000 (UTC) Received: from laptop.redhat.com (ovpn-112-13.ams2.redhat.com [10.36.112.13]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3166B10027C4; Sun, 4 Apr 2021 17:22:55 +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, alexandru.elisei@arm.com Cc: james.morse@arm.com, suzuki.poulose@arm.com, shuah@kernel.org, pbonzini@redhat.com Subject: [PATCH v5 2/8] KVM: arm64: vgic-v3: Fix error handling in vgic_v3_set_redist_base() Date: Sun, 4 Apr 2021 19:22:37 +0200 Message-Id: <20210404172243.504309-3-eric.auger@redhat.com> In-Reply-To: <20210404172243.504309-1-eric.auger@redhat.com> References: <20210404172243.504309-1-eric.auger@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org vgic_v3_insert_redist_region() may succeed while vgic_register_all_redist_iodevs fails. For example this happens 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 vgic_register_redist_iodev(). In such a case, remove the newly added redistributor region and free it. Signed-off-by: Eric Auger --- v1 -> v2: - fix the commit message and split declaration/assignment of rdreg --- 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 ef9baf0d01b5..fec0555529c0 100644 --- a/arch/arm64/kvm/vgic/vgic-mmio-v3.c +++ b/arch/arm64/kvm/vgic/vgic-mmio-v3.c @@ -861,8 +861,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; + + rdreg = vgic_v3_rdist_region_from_index(kvm, index); + list_del(&rdreg->list); + kfree(rdreg); return ret; + } return 0; } -- 2.26.3