From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2F2F62E612E for ; Thu, 22 Jan 2026 13:25:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769088316; cv=none; b=tgrGIjw7iNe41qOASZGh/cOAQa5BZe22BO3hXXnh0lbv9tdMBrIG02TQPHJX3U4uO55XGL0TpJlDiVDYnspCvhL59FbvAGv3Q9V4SpDz9DSKDJEUvNQL0+UIx1qEbNJHnzSmpWTeVlJwnxPEeriLzGR/BvCs8a7FrQX/KLLR2oI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769088316; c=relaxed/simple; bh=d1MizkSspn35pSSs7WFrLUELoQ81+EVmGUW7ZT92Lrk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ndZY79DKTeFa0rKxdA36SNNqU9aSigGRJpAGWyCZ6L8U59weDixrHg+jOzYqWsd+3vr3YBLUeeZS1TDKm4TkT9Vj5n53mGXumoI5UJNzBfqlnWyYZTNeVnRILdTpoVTTrfQmIfqAl+NmCicCFX9SqSaGjfkm6FLXR7gdfqQoGUQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YrWDFB4L; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="YrWDFB4L" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 51BE2C116C6; Thu, 22 Jan 2026 13:25:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769088315; bh=d1MizkSspn35pSSs7WFrLUELoQ81+EVmGUW7ZT92Lrk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=YrWDFB4LDs5qEsCqYCX4YttxexqobOOT5/sJCBLb0TEh9RryY3YsPgJZ/e5riSTlR IQ30Vc0vhpPtnYWppdOv4w+ZHtC8SNvTXJ8Kif6FC36DzL2brlBX+okaosbATHG8DH OiYwZLCElV2t0XYYeIHbXIiql8paKwShrc3rN80YTviSbeSNBx3NvpQpZlrT99h8QJ lcXzaakIx/Lee+fvfPbbHkIMGcXMFp56ydFtnTcHz+NXe0rS/olpls4/T2D8QlvNAT ed+eqflFLefMPQSfIEQwJP82SaiVpEjY5Olt34bHZaoNrvsc7amCvDKhh1gdK63vB1 TJJtGQeF9zNsQ== Date: Thu, 22 Jan 2026 15:25:09 +0200 From: Mike Rapoport To: Andrew Morton Cc: Alexander Graf , Pasha Tatashin , Pratyush Yadav , kexec@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH] kho: cleanup error handling in kho_populate() Message-ID: References: <20260122121757.575987-1-rppt@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260122121757.575987-1-rppt@kernel.org> (cc the correct Pratyush's address) On Thu, Jan 22, 2026 at 02:17:57PM +0200, Mike Rapoport wrote: > From: "Mike Rapoport (Microsoft)" > > * use dedicated labels for error handling instead of checking if a pointer > is not null to decide if it should be unmapped > * drop assignment of values to err that are only used to print a numeric > error code, there are pr_warn()s for each failure already so printing a > numeric error code in the next line does not add anything useful > > Signed-off-by: Mike Rapoport (Microsoft) > --- > kernel/liveupdate/kexec_handover.c | 39 +++++++++++++----------------- > 1 file changed, 17 insertions(+), 22 deletions(-) > > diff --git a/kernel/liveupdate/kexec_handover.c b/kernel/liveupdate/kexec_handover.c > index d4482b6e3cae..e248ce2e04b7 100644 > --- a/kernel/liveupdate/kexec_handover.c > +++ b/kernel/liveupdate/kexec_handover.c > @@ -1441,46 +1441,40 @@ void __init kho_memory_init(void) > void __init kho_populate(phys_addr_t fdt_phys, u64 fdt_len, > phys_addr_t scratch_phys, u64 scratch_len) > { > + unsigned int scratch_cnt = scratch_len / sizeof(*kho_scratch); > struct kho_scratch *scratch = NULL; > phys_addr_t mem_map_phys; > void *fdt = NULL; > - int err = 0; > - unsigned int scratch_cnt = scratch_len / sizeof(*kho_scratch); > + int err; > > /* Validate the input FDT */ > fdt = early_memremap(fdt_phys, fdt_len); > if (!fdt) { > pr_warn("setup: failed to memremap FDT (0x%llx)\n", fdt_phys); > - err = -EFAULT; > - goto out; > + goto err_report; > } > err = fdt_check_header(fdt); > if (err) { > pr_warn("setup: handover FDT (0x%llx) is invalid: %d\n", > fdt_phys, err); > - err = -EINVAL; > - goto out; > + goto err_unmap_fdt; > } > err = fdt_node_check_compatible(fdt, 0, KHO_FDT_COMPATIBLE); > if (err) { > pr_warn("setup: handover FDT (0x%llx) is incompatible with '%s': %d\n", > fdt_phys, KHO_FDT_COMPATIBLE, err); > - err = -EINVAL; > - goto out; > + goto err_unmap_fdt; > } > > mem_map_phys = kho_get_mem_map_phys(fdt); > - if (!mem_map_phys) { > - err = -ENOENT; > - goto out; > - } > + if (!mem_map_phys) > + goto err_unmap_fdt; > > scratch = early_memremap(scratch_phys, scratch_len); > if (!scratch) { > pr_warn("setup: failed to memremap scratch (phys=0x%llx, len=%lld)\n", > scratch_phys, scratch_len); > - err = -EFAULT; > - goto out; > + goto err_unmap_fdt; > } > > /* > @@ -1497,7 +1491,7 @@ void __init kho_populate(phys_addr_t fdt_phys, u64 fdt_len, > if (WARN_ON(err)) { > pr_warn("failed to mark the scratch region 0x%pa+0x%pa: %pe", > &area->addr, &size, ERR_PTR(err)); > - goto out; > + goto err_unmap_scratch; > } > pr_debug("Marked 0x%pa+0x%pa as scratch", &area->addr, &size); > } > @@ -1519,13 +1513,14 @@ void __init kho_populate(phys_addr_t fdt_phys, u64 fdt_len, > kho_scratch_cnt = scratch_cnt; > pr_info("found kexec handover data.\n"); > > -out: > - if (fdt) > - early_memunmap(fdt, fdt_len); > - if (scratch) > - early_memunmap(scratch, scratch_len); > - if (err) > - pr_warn("disabling KHO revival: %d\n", err); > + return; > + > +err_unmap_scratch: > + early_memunmap(scratch, scratch_len); > +err_unmap_fdt: > + early_memunmap(fdt, fdt_len); > +err_report: > + pr_warn("disabling KHO revival\n"); > } > > /* Helper functions for kexec_file_load */ > > base-commit: 24d479d26b25bce5faea3ddd9fa8f3a6c3129ea7 > -- > 2.51.0 > -- Sincerely yours, Mike.