binfmt_elf_fdpic: fix variable set but not used warning
authorsunliming <sunliming@kylinos.cn>
Sat, 8 Mar 2025 02:27:54 +0000 (10:27 +0800)
committerKees Cook <kees@kernel.org>
Sat, 8 Mar 2025 04:07:33 +0000 (20:07 -0800)
Fix below kernel warning:
fs/binfmt_elf_fdpic.c:1024:52: warning: variable 'excess1' set but not
used [-Wunused-but-set-variable]

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: sunliming <sunliming@kylinos.cn>
Reviewed-by: Jan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/20250308022754.75013-1-sunliming@linux.dev
Signed-off-by: Kees Cook <kees@kernel.org>
fs/binfmt_elf_fdpic.c

index e3cf280..9133f38 100644 (file)
@@ -1024,7 +1024,7 @@ static int elf_fdpic_map_file_by_direct_mmap(struct elf_fdpic_params *params,
        /* deal with each load segment separately */
        phdr = params->phdrs;
        for (loop = 0; loop < params->hdr.e_phnum; loop++, phdr++) {
-               unsigned long maddr, disp, excess, excess1;
+               unsigned long maddr, disp, excess;
                int prot = 0, flags;
 
                if (phdr->p_type != PT_LOAD)
@@ -1120,9 +1120,10 @@ static int elf_fdpic_map_file_by_direct_mmap(struct elf_fdpic_params *params,
                 *   extant in the file
                 */
                excess = phdr->p_memsz - phdr->p_filesz;
-               excess1 = PAGE_SIZE - ((maddr + phdr->p_filesz) & ~PAGE_MASK);
 
 #ifdef CONFIG_MMU
+               unsigned long excess1
+                       = PAGE_SIZE - ((maddr + phdr->p_filesz) & ~PAGE_MASK);
                if (excess > excess1) {
                        unsigned long xaddr = maddr + phdr->p_filesz + excess1;
                        unsigned long xmaddr;