Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp679644rwi; Wed, 19 Oct 2022 01:14:28 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7qSCLeFaoEFA8cQ+hzJhWGaCV07PPUJKCgJkszELdeQiR7xp3xRn5qxhKmbu8FNfOZkcb4 X-Received: by 2002:a05:6402:350f:b0:45d:1d86:9ec9 with SMTP id b15-20020a056402350f00b0045d1d869ec9mr6366285edd.266.1666167268294; Wed, 19 Oct 2022 01:14:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666167268; cv=none; d=google.com; s=arc-20160816; b=slJRfjY/TKc8UAVZWbvk6aOPBUqIFaQuWQ2kOZKBsBksHzFY21hGCt5KJDeunXC+KD adLyMkzFuB+fpD11p0H/TOBCo2rKjNwpCz0lUstwumMpgjRz8kYX0IIWpRhMYc3CIE6W S48A/1El6Vh7K1etcgaqcvwFdfsi3wnFpHwjqrw6rmjqCxoLGOfIhLqwpZEnP9D4h8hH atBtQ140GIzV58gU+OrCppT86QuHuOsftRekuIQXd7KHteSqYDkT6YU4V4yWPI2PT0dr mPS0zK4T6kSqxDFJZqbe5Kw+azSruyLIOv2yEWMHbyXztz3+odeKMLU+7sBC7VVR7RMS sB9A== 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 :message-id:date:subject:cc:to:from; bh=XDghgOn+Lb0oRgTDskdQjkEallIdrLvwEhDqFaFhuNw=; b=e0m4rnKNYvdx8RdDJdPGLMjJj5hSX8FqXiN8XZe7PZDj/OdIrw1aIQkibgl3mZudA+ J02755FEQdIy/y9358Qy47vilqkV4gtpjn1hJtDQbYyY4x73v9t59uvAg70VONUOJhPF 6j3ambFns3x73Ux2XNmkuRHMlFXEcP1C4nFiaYtVn1Lc3bwt0sT6Br6tBfrQChpfqXiJ /WBcjgrAD/tfP4JPNN1r9+h8I0sWvkJkBDwKQJGdJbY6jD/HQ6i7LbKfMCgfPvzka1NY hGpOYKlI/9r3NhE3PiaPwEY7UjD52EV89CfzgGc9jCzh/UgbXucOZRAT04kl+/SQ7W6p TJqQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id en16-20020a056402529000b00457166171c6si11529183edb.432.2022.10.19.01.14.00; Wed, 19 Oct 2022 01:14:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230150AbiJSHwc convert rfc822-to-8bit (ORCPT + 99 others); Wed, 19 Oct 2022 03:52:32 -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: 8BIT Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The err variable was the same like retval, but capped to <= 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 elfhdr *elf_ex, struct file *elf_file) { struct elf_phdr *elf_phdata = NULL; - int retval, err = -1; + int retval = -1; unsigned int size; /* @@ -484,15 +484,9 @@ static struct elf_phdr *load_elf_phdrs(const struct elfhdr *elf_ex, /* Read in the program headers */ retval = elf_read(elf_file, elf_phdata, size, elf_ex->e_phoff); - if (retval < 0) { - err = retval; - goto out; - } - /* Success! */ - err = 0; out: - if (err) { + if (retval) { kfree(elf_phdata); elf_phdata = NULL; } -- 2.37.3 -- Rolf Eike Beer, emlix GmbH, https://www.emlix.com Fon +49 551 30664-0, Fax +49 551 30664-11 Gothaer Platz 3, 37083 Göttingen, Germany Sitz der Gesellschaft: Göttingen, Amtsgericht Göttingen HR B 3160 Geschäftsführung: Heike Jordan, Dr. Uwe Kracke – Ust-IdNr.: DE 205 198 055 emlix - smart embedded open source