Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp1115855pxb; Tue, 3 Nov 2020 23:54:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJzMovIcIgH3/6IIRP1d9Ap/+MH+VA364u5g5axr46LqXGrfeiRw6n5pBm8LLwXhWcUbK/zD X-Received: by 2002:a17:906:7e43:: with SMTP id z3mr24968061ejr.143.1604476448367; Tue, 03 Nov 2020 23:54:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604476448; cv=none; d=google.com; s=arc-20160816; b=S28VY6m8ZW1LFit+nTiU4bfDW3+G021TmwkneE883cVTPwVl+7FjehDNfEgzAhyY6V P9WH/IWJlbGGDCXxAgytjgX989HKbfA4XfIFE4Fe6TIyaXS0hsOmeVaNy/xoeO7lxZds 6fZ4GSN30LSaEPr/QH5gENQyrhb4pRD3cQnncpwgDR0GwgMbkxaTVYvLFZkNe3lk9JkD RrN35vltUMOITIAdXx96RcPmUuLDZgYBjhPXbMmU3i8Vzl5CaXAT/o71KexODrlzmgP0 TdUKm0ZcAhnnphFMh8naZjLe//xhNHCShrv602WfL69UJXa/SGGVlcQd6aoxMDVW/ilt kULg== 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 :organization:message-id:date:subject:cc:to:from; bh=6OkXF95XML1aF/ZOerTJ35fu0VqxQJ3EPNcDb7vQ+sA=; b=f9/4ugyOjOz+ACtZOPFlynlnr/2gRFg731c1jFNKJ6ojKY49VXa0W3z0L5nII60tf2 VgWGJFteDsldl5heowUwKock/KMcp1qVnQclUAIbz5c/xwAoZN9L1Q5gdKX2PUwQAaCJ kF9PrhReX0me4fAgiHYeUmPk6X+8a6DEasWetYAm0uv53o/fhlXdCXYR8fNxehQkRUjx ya8LMNl4NbbrZTqGSPzjyCVD+YaDxoEiZRhkh79O/eTu/gMJqLlJ2Wxk6SkjYy5lsKO/ ai96XWEl7X8n71AzMRNbYAJ0RVV6GGY/L0hlLQ5oGHsKsS9Q2feVkykQN9esLAi5yuTI gSQQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m16si956325ejc.357.2020.11.03.23.53.44; Tue, 03 Nov 2020 23:54:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727110AbgKDHv5 convert rfc822-to-8bit (ORCPT + 99 others); Wed, 4 Nov 2020 02:51:57 -0500 Received: from mx1.emlix.com ([136.243.223.33]:44506 "EHLO mx1.emlix.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728518AbgKDHv5 (ORCPT ); Wed, 4 Nov 2020 02:51:57 -0500 X-Greylist: delayed 538 seconds by postgrey-1.27 at vger.kernel.org; Wed, 04 Nov 2020 02:51:56 EST 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 DF3BB6046C; Wed, 4 Nov 2020 08:42:57 +0100 (CET) From: Rolf Eike Beer To: Alexander Viro Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] binfmt_elf: simplify error handling in load_elf_phdrs() Date: Wed, 04 Nov 2020 08:42:58 +0100 Message-ID: <1810206.T5v88Pq2cJ@devpool47> Organization: emlix GmbH MIME-Version: 1.0 Content-Transfer-Encoding: 8BIT Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 b588d1291b25..74827a7a06d0 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c @@ -458,7 +458,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; /* @@ -480,15 +480,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.29.1 -- Rolf Eike Beer, emlix GmbH, http://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