Commit 17a9be31 authored by Stafford Horne's avatar Stafford Horne

initramfs: Always do fput() and load modules after rootfs populate

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 08865514 ("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: 08865514 ("initramfs: finish fput() before accessing any binary from initramfs")
Cc: stable@vger.kernel.org
Cc: Lokesh Vutla <lokeshvutla@ti.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Acked-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
Signed-off-by: default avatarStafford Horne <shorne@gmail.com>
parent a351e9b9
...@@ -608,9 +608,11 @@ static void __init clean_rootfs(void) ...@@ -608,9 +608,11 @@ static void __init clean_rootfs(void)
static int __init populate_rootfs(void) static int __init populate_rootfs(void)
{ {
/* Load the built in initramfs */
char *err = unpack_to_rootfs(__initramfs_start, __initramfs_size); char *err = unpack_to_rootfs(__initramfs_start, __initramfs_size);
if (err) if (err)
panic("%s", err); /* Failed to decompress INTERNAL initramfs */ panic("%s", err); /* Failed to decompress INTERNAL initramfs */
/* If available load the bootloader supplied initrd */
if (initrd_start) { if (initrd_start) {
#ifdef CONFIG_BLK_DEV_RAM #ifdef CONFIG_BLK_DEV_RAM
int fd; int fd;
...@@ -648,13 +650,14 @@ static int __init populate_rootfs(void) ...@@ -648,13 +650,14 @@ static int __init populate_rootfs(void)
printk(KERN_EMERG "Initramfs unpacking failed: %s\n", err); printk(KERN_EMERG "Initramfs unpacking failed: %s\n", err);
free_initrd(); free_initrd();
#endif #endif
}
flush_delayed_fput(); flush_delayed_fput();
/* /*
* Try loading default modules from initramfs. This gives * Try loading default modules from initramfs. This gives
* us a chance to load before device_initcalls. * us a chance to load before device_initcalls.
*/ */
load_default_modules(); load_default_modules();
}
return 0; return 0;
} }
rootfs_initcall(populate_rootfs); rootfs_initcall(populate_rootfs);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment