From patchwork Wed Oct 19 07:52:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rolf Eike Beer X-Patchwork-Id: 4472 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp193577wrs; Wed, 19 Oct 2022 01:13:35 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5VvIo8vRh4oV/naCzUxAEfZ6EMUM4MEJekePur1318pBqLNtzXfzoZp4ACT74jODiN90sB X-Received: by 2002:a17:906:cc5a:b0:78d:c3cf:6ff7 with SMTP id mm26-20020a170906cc5a00b0078dc3cf6ff7mr5687717ejb.383.1666167215102; Wed, 19 Oct 2022 01:13:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666167215; cv=none; d=google.com; s=arc-20160816; b=LpJtykvD+akW2o9ExQKUIMBqEhy9b6HHBnA3ljGm1VQ6CamzvkOpKhmTiTxWzfaoDC Zh4uNmagj95tEczdGRfO53zkb7r7BFJ5KvaQFAGBF7YIsIlob4T1L8LCK9OZlTzXD1X+ z+FVH9o3v2hQypG3Pi92qgXjhTiYX8I9M7JA9yc44H0Jfk11RCw1zwulCc7fpFtuJVkw mCSl5QhN8/WZeB98pW0QY6TqEjQjCvEox390U1qVEcjXoaDiajCerNCuyZHAZW/wbgLR p5Uc5XwYE/YFnx0YbLqZQrQ7iGM0rQOThCxp+Js1n58KTK9rH9tdKBD+L4nJA7d/PZWM zw+Q== 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 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.13.09; Wed, 19 Oct 2022 01:13:35 -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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747102953740788630?= X-GMAIL-MSGID: =?utf-8?q?1747102953740788630?= 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; }