Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9142304pxu; Mon, 28 Dec 2020 07:39:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJy/36EGHS5oQiI3VWUgCdJyz0NdJsLsMGxCU9UwqTDUZnAGWZqTm1kpTP7Bx2EMJuUe3/zA X-Received: by 2002:a17:906:851:: with SMTP id f17mr42297996ejd.392.1609169973376; Mon, 28 Dec 2020 07:39:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609169973; cv=none; d=google.com; s=arc-20160816; b=MmcWqPqPKchWDTUYLXdkOs5NfYC70OQRmbrJ4FO8e6BA1Ph8VpEzKXmZh1EvD8rj2C S/XIH5UwvbXJJF/p5fih7OYyODlpDfvTooPklUazSTiUQC5F7hvnnkAmH/hDu3DxP75z W85hyq0899THYVBPf7UYkAOEaEGMuiVhV6plY3dKyf0Q6inwVwgpPxSrxdpdDk/Joa4A iJr37KzYE8dLFNMPdh5txzMlcG4irNjXkmrrpAWOlGNHgT6yFRPsja6ZkI629ZL/hqU4 y91B+TVvjU7/u/lmZ/L8uA2ufQs2ib6MRAqDrccqrBv3J5VAL8HLsefrj23XVy1u9wzg o2gg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date; bh=YNxhQ97QdRY9ZW6/jALrEV5fsvHmv1PJAkOs5Bhmuvs=; b=AsHkLGEEBAdmaXPaQPXfCWLDeKjYDDmD8Axx7KrlwczeiaTvVPAbyvyk1j+bcwAg6o HxsIeeOklYlge8QJtFOCZ2yLS1zKic1s0Z1At4Z0DdTO2W51EwqbWAbBqq9guj0Mqk8j BCUQK4cUvmKx+TIGtru574JUUXFlFKV2fOE5/vqDTmAYJFTyVTKB+u6E5sBUn/xf4s+R h43gF0XD9YSFrcSt/SuLVyCbEVltLVT6COV7scAWoEX/N+1wilOpX0XPYHgHSHSkZpLd PGgs+ZjTFt2ufY006gKAgYVpz7bz91RZulF3T/YfhPYGNn5ZTqduoDKu7zRZjPtf2EpX uqlQ== ARC-Authentication-Results: i=1; mx.google.com; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lz11si18868611ejb.341.2020.12.28.07.39.10; Mon, 28 Dec 2020 07:39:33 -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; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2407414AbgL1Pg6 (ORCPT + 99 others); Mon, 28 Dec 2020 10:36:58 -0500 Received: from mail.kernel.org ([198.145.29.99]:38006 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2408674AbgL1Pfz (ORCPT ); Mon, 28 Dec 2020 10:35:55 -0500 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 44B2922475; Mon, 28 Dec 2020 15:35:14 +0000 (UTC) Received: from 78.163-31-62.static.virginmediabusiness.co.uk ([62.31.163.78] helo=wait-a-minute.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94) (envelope-from ) id 1ktuYC-004FUG-4O; Mon, 28 Dec 2020 15:35:12 +0000 Date: Mon, 28 Dec 2020 15:35:11 +0000 Message-ID: <87a6tyoseo.wl-maz@kernel.org> From: Marc Zyngier To: Eric Auger Cc: eric.auger.pro@gmail.com, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu, drjones@redhat.com, alexandru.elisei@arm.com, james.morse@arm.com, julien.thierry.kdev@gmail.com, suzuki.poulose@arm.com, shuah@kernel.org, pbonzini@redhat.com Subject: Re: [PATCH 3/9] KVM: arm64: vgic-v3: Fix error handling in vgic_v3_set_redist_base() In-Reply-To: <20201212185010.26579-4-eric.auger@redhat.com> References: <20201212185010.26579-1-eric.auger@redhat.com> <20201212185010.26579-4-eric.auger@redhat.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 62.31.163.78 X-SA-Exim-Rcpt-To: eric.auger@redhat.com, eric.auger.pro@gmail.com, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu, drjones@redhat.com, alexandru.elisei@arm.com, james.morse@arm.com, julien.thierry.kdev@gmail.com, suzuki.poulose@arm.com, shuah@kernel.org, pbonzini@redhat.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Eric, On Sat, 12 Dec 2020 18:50:04 +0000, Eric Auger wrote: > > vgic_register_all_redist_iodevs may succeed while > vgic_register_all_redist_iodevs fails. For example this can happen The same function cannot both fail and succeed ;-) Can you shed some light on what you had in mind? > 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); > + nit: consider splitting declaration and assignment so that we avoid the line split if you insist on the 80 character limit. > + list_del(&rdreg->list); > + kfree(rdreg); > return ret; > + } > > return 0; > } > -- > 2.21.3 > > Thanks, M. -- Without deviation from the norm, progress is not possible.