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: 13011446 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D6863C4332F for ; Wed, 19 Oct 2022 07:52:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 644656B0072; Wed, 19 Oct 2022 03:52:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5CD956B0073; Wed, 19 Oct 2022 03:52:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 496536B0074; Wed, 19 Oct 2022 03:52:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 35D776B0072 for ; Wed, 19 Oct 2022 03:52:29 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 1545C160438 for ; Wed, 19 Oct 2022 07:52:29 +0000 (UTC) X-FDA: 80036931618.04.E7EA74A Received: from mx1.emlix.com (mx1.emlix.com [136.243.223.33]) by imf08.hostedemail.com (Postfix) with ESMTP id 53A5F160034 for ; Wed, 19 Oct 2022 07:52:28 +0000 (UTC) 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 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666165948; a=rsa-sha256; cv=none; b=ZQHgxIbd1IPqILyUPrbSdMgr3bb97rXd9yEa9gJdcoDhPuC+FkAx4JyxmQamObeEGU3ZiJ Vfmx+y+SpK0n6815nGSD5U2J1U4pHQLOfxirA/ddTUGceWRXNsa5HIhlvBXrujUN3S8UVQ E0sDVHl3HpHSU596DqPcXjwG8hhvYE8= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf08.hostedemail.com: domain of eb@emlix.com designates 136.243.223.33 as permitted sender) smtp.mailfrom=eb@emlix.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1666165948; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references; bh=gUNg9QiHhZujUtKeG9dOdYyCO8791cQltAFF6rrkWmE=; b=BOiE7ZQ/2h3hf9tn74/A2t+kQJ/ta0uQk/3ne6lID5KIjrOit8PTRk5pQWgVxSdoqIGZc7 QX+q9SRaO5Tdig7EnwJBwrJV6joY8GdRLyFYYaU++v+6tHqzJQrH1OkuVGrxLvuEDh9NU3 oaW1sdotErjj7B1AH8+RiBM0Zgyx38o= X-Rspamd-Queue-Id: 53A5F160034 Authentication-Results: imf08.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf08.hostedemail.com: domain of eb@emlix.com designates 136.243.223.33 as permitted sender) smtp.mailfrom=eb@emlix.com X-Rspam-User: X-Rspamd-Server: rspam08 X-Stat-Signature: h8gzwz4wqmg84m8939ymqx47p3xhey4n X-HE-Tag: 1666165948-579834 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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; }