From nobody Tue Apr 7 19:02:23 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B576EC433FE for ; Wed, 19 Oct 2022 07:52:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230154AbiJSHwd convert rfc822-to-8bit (ORCPT ); Wed, 19 Oct 2022 03:52:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229525AbiJSHwa (ORCPT ); Wed, 19 Oct 2022 03:52:30 -0400 Received: from mx1.emlix.com (mx1.emlix.com [136.243.223.33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 556671055D; Wed, 19 Oct 2022 00:52:28 -0700 (PDT) Received: from mailer.emlix.com (p5098be52.dip0.t-ipconnect.de [80.152.190.82]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.emlix.com (Postfix) with ESMTPS id D99715FE74; Wed, 19 Oct 2022 09:52:26 +0200 (CEST) From: Rolf Eike Beer To: Alexander Viro , Eric Biederman , Kees Cook Cc: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH] binfmt_elf: simplify error handling in load_elf_phdrs() Date: Wed, 19 Oct 2022 09:52:16 +0200 Message-ID: <4137126.7Qn9TF0dmF@mobilepool36.emlix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The err variable was the same like retval, but capped to <=3D 0. This is the same as retval as elf_read() never returns positive values. Signed-off-by: Rolf Eike Beer --- fs/binfmt_elf.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index cfd5f7ad019d..1fdc92e95170 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c @@ -462,7 +462,7 @@ static struct elf_phdr *load_elf_phdrs(const struct elf= hdr *elf_ex, struct file *elf_file) { struct elf_phdr *elf_phdata =3D NULL; - int retval, err =3D -1; + int retval =3D -1; unsigned int size; =20 /* @@ -484,15 +484,9 @@ static struct elf_phdr *load_elf_phdrs(const struct el= fhdr *elf_ex, =20 /* Read in the program headers */ retval =3D elf_read(elf_file, elf_phdata, size, elf_ex->e_phoff); - if (retval < 0) { - err =3D retval; - goto out; - } =20 - /* Success! */ - err =3D 0; out: - if (err) { + if (retval) { kfree(elf_phdata); elf_phdata =3D NULL; } --=20 2.37.3 --=20 Rolf Eike Beer, emlix GmbH, https://www.emlix.com Fon +49 551 30664-0, Fax +49 551 30664-11 Gothaer Platz 3, 37083 G=C3=B6ttingen, Germany Sitz der Gesellschaft: G=C3=B6ttingen, Amtsgericht G=C3=B6ttingen HR B 3160 Gesch=C3=A4ftsf=C3=BChrung: Heike Jordan, Dr. Uwe Kracke =E2=80=93 Ust-IdNr= .: DE 205 198 055 emlix - smart embedded open source