Skip to content

Commit 17a9be3

Browse files
committed
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 0886551 ("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: 0886551 ("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: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Stafford Horne <shorne@gmail.com>
1 parent a351e9b commit 17a9be3

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

init/initramfs.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -608,9 +608,11 @@ static void __init clean_rootfs(void)
608608

609609
static int __init populate_rootfs(void)
610610
{
611+
/* Load the built in initramfs */
611612
char *err = unpack_to_rootfs(__initramfs_start, __initramfs_size);
612613
if (err)
613614
panic("%s", err); /* Failed to decompress INTERNAL initramfs */
615+
/* If available load the bootloader supplied initrd */
614616
if (initrd_start) {
615617
#ifdef CONFIG_BLK_DEV_RAM
616618
int fd;
@@ -648,13 +650,14 @@ static int __init populate_rootfs(void)
648650
printk(KERN_EMERG "Initramfs unpacking failed: %s\n", err);
649651
free_initrd();
650652
#endif
651-
flush_delayed_fput();
652-
/*
653-
* Try loading default modules from initramfs. This gives
654-
* us a chance to load before device_initcalls.
655-
*/
656-
load_default_modules();
657653
}
654+
flush_delayed_fput();
655+
/*
656+
* Try loading default modules from initramfs. This gives
657+
* us a chance to load before device_initcalls.
658+
*/
659+
load_default_modules();
660+
658661
return 0;
659662
}
660663
rootfs_initcall(populate_rootfs);

0 commit comments

Comments
 (0)