From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753669AbdEDMr7 (ORCPT ); Thu, 4 May 2017 08:47:59 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:33044 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751351AbdEDMrq (ORCPT ); Thu, 4 May 2017 08:47:46 -0400 From: Stafford Horne To: LKML Cc: Stafford Horne , Lokesh Vutla , Al Viro , Andrew Morton Subject: [PATCH] initramfs: Always do fput() and load modules after rootfs populate Date: Thu, 4 May 2017 21:47:00 +0900 Message-Id: <20170504124701.727-1-shorne@gmail.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170504094109.GC17317@lianli.shorne-pla.net> References: <20170504094109.GC17317@lianli.shorne-pla.net> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In OpenRISC we do not have a bootloader passed initrd, but the built in initramfs does contain the /init and other binaries, including modules. The previous commit 08865514805d2 ("initramfs: finish fput() before accessing any binary from initramfs") made a change to only call fput() if the bootloader initrd was available, this caused intermittent crashes for OpenRISC. This patch changes the fput() to happen unconditionally if any rootfs is loaded. Also, I added some comments to make it a bit more clear why we call unpack_to_rootfs() multiple times. Fixes: 08865514805d2 ("initramfs: finish fput() before accessing any binary from initramfs") Cc: Lokesh Vutla Cc: Al Viro Signed-off-by: Stafford Horne --- init/initramfs.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/init/initramfs.c b/init/initramfs.c index 981f286..3a68715 100644 --- a/init/initramfs.c +++ b/init/initramfs.c @@ -608,9 +608,11 @@ static void __init clean_rootfs(void) static int __init populate_rootfs(void) { + /* Load the built in initramfs */ char *err = unpack_to_rootfs(__initramfs_start, __initramfs_size); if (err) panic("%s", err); /* Failed to decompress INTERNAL initramfs */ + /* If available load the bootloader supplied initrd */ if (initrd_start) { #ifdef CONFIG_BLK_DEV_RAM int fd; @@ -648,13 +650,14 @@ static int __init populate_rootfs(void) printk(KERN_EMERG "Initramfs unpacking failed: %s\n", err); free_initrd(); #endif - flush_delayed_fput(); - /* - * Try loading default modules from initramfs. This gives - * us a chance to load before device_initcalls. - */ - load_default_modules(); } + flush_delayed_fput(); + /* + * Try loading default modules from initramfs. This gives + * us a chance to load before device_initcalls. + */ + load_default_modules(); + return 0; } rootfs_initcall(populate_rootfs); -- 2.9.3