Skip to content

Commit

Permalink
initramfs: Always do fput() and load modules after rootfs populate
Browse files Browse the repository at this point in the history
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: [email protected]
Cc: Lokesh Vutla <[email protected]>
Cc: Al Viro <[email protected]>
Acked-by: Al Viro <[email protected]>
Signed-off-by: Stafford Horne <[email protected]>
  • Loading branch information
stffrdhrn committed May 5, 2017
1 parent a351e9b commit 17a9be3
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions init/initramfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

0 comments on commit 17a9be3

Please sign in to comment.