From patchwork Sun May 28 16:20:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 13257864 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 D6729C7EE33 for ; Sun, 28 May 2023 16:20:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229641AbjE1QUp (ORCPT ); Sun, 28 May 2023 12:20:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229633AbjE1QUo (ORCPT ); Sun, 28 May 2023 12:20:44 -0400 Received: from smtp.smtpout.orange.fr (smtp-17.smtpout.orange.fr [80.12.242.17]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0D0CBE for ; Sun, 28 May 2023 09:20:42 -0700 (PDT) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id 3J87qJcsWrDwx3J8KqjZT0; Sun, 28 May 2023 18:20:41 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1685290841; bh=0xJS/fpIMbVgICwjevG2Mh+kQS4ETIrWvAeZpBHPlyk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=CBwvekAV1qKxJ4DwNqJ9ZDO8acOPtMMg7Q+s4w4fKGbs2vPD7lOV9bOSC4EI2vg4M qWZaaXL7whDH7BvYKkoTs6xIAtYksqhzfEtIUf9gQTRoSoIUVFxoVqHeIEugaQ1U7E CoQ7h2Wo6Fns43siy2gzzdgF5LVRjW+zxjS7t47FmlOloWjca03H6LskQi5vMINkH8 MunknPlfBTPdPZFUEaGKzlaSAA2yJERP3fUHh5Ng9udhrXyXWVqqdJsml+CHZcmst9 vBSXNuRwpT4Lf7pZsMpXtBbKAdlnWBlgkxNaUa5v7Z/10k6HZdHMCrBXXwBg5zYHE1 F6HtkeE+iygIA== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sun, 28 May 2023 18:20:41 +0200 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: Alexander Viro , Christian Brauner , Eric Biederman , Kees Cook Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 2/2] binfmt: Slightly simplify elf_fdpic_map_file() Date: Sun, 28 May 2023 18:20:25 +0200 Message-Id: <4f5e4096ad7f17716e924b5bd080e5709fc0b84b.1685290790.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 In-Reply-To: <53150beae5dc04dac513dba391a2e4ae8696a7f3.1685290790.git.christophe.jaillet@wanadoo.fr> References: <53150beae5dc04dac513dba391a2e4ae8696a7f3.1685290790.git.christophe.jaillet@wanadoo.fr> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org There is no point in initializing 'load_addr' and 'seg' here, they are both re-written just before being used below. Doing so, 'load_addr' can be moved in the #ifdef CONFIG_MMU section. Signed-off-by: Christophe JAILLET Acked-by: "Eric W. Biederman" --- Compile tested on arm, with and without CONFIG_MMU --- fs/binfmt_elf_fdpic.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c index 237ce388d06d..1c6c5832af86 100644 --- a/fs/binfmt_elf_fdpic.c +++ b/fs/binfmt_elf_fdpic.c @@ -743,11 +743,12 @@ static int elf_fdpic_map_file(struct elf_fdpic_params *params, struct elf32_fdpic_loadmap *loadmap; #ifdef CONFIG_MMU struct elf32_fdpic_loadseg *mseg; + unsigned long load_addr; #endif struct elf32_fdpic_loadseg *seg; struct elf32_phdr *phdr; - unsigned long load_addr, stop; unsigned nloads, tmp; + unsigned long stop; int loop, ret; /* allocate a load map table */ @@ -768,9 +769,6 @@ static int elf_fdpic_map_file(struct elf_fdpic_params *params, loadmap->version = ELF32_FDPIC_LOADMAP_VERSION; loadmap->nsegs = nloads; - load_addr = params->load_addr; - seg = loadmap->segs; - /* map the requested LOADs into the memory space */ switch (params->flags & ELF_FDPIC_FLAG_ARRANGEMENT) { case ELF_FDPIC_FLAG_CONSTDISP: