Skip to content

Commit 5d59aa8

Browse files
Steven Pricetorvalds
authored andcommitted
initramfs: don't free a non-existent initrd
Since commit 54c7a89 ("initramfs: free initrd memory if opening /initrd.image fails"), the kernel has unconditionally attempted to free the initrd even if it doesn't exist. In the non-existent case this causes a boot-time splat if CONFIG_DEBUG_VIRTUAL is enabled due to a call to virt_to_phys() with a NULL address. Instead we should check that the initrd actually exists and only attempt to free it if it does. Link: http://lkml.kernel.org/r/[email protected] Fixes: 54c7a89 ("initramfs: free initrd memory if opening /initrd.image fails") Signed-off-by: Steven Price <[email protected]> Reported-by: Mark Rutland <[email protected]> Tested-by: Mark Rutland <[email protected]> Reviewed-by: Mike Rapoport <[email protected]> Cc: Christoph Hellwig <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent ec084de commit 5d59aa8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

init/initramfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ static int __init populate_rootfs(void)
669669
* If the initrd region is overlapped with crashkernel reserved region,
670670
* free only memory that is not part of crashkernel region.
671671
*/
672-
if (!do_retain_initrd && !kexec_free_initrd())
672+
if (!do_retain_initrd && initrd_start && !kexec_free_initrd())
673673
free_initrd_mem(initrd_start, initrd_end);
674674
initrd_start = 0;
675675
initrd_end = 0;

0 commit comments

Comments
 (0)