Skip to content

Commit 5d59aa8

Browse files
stevenprice-armtorvalds
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/20190516143125.48948-1-steven.price@arm.com Fixes: 54c7a89 ("initramfs: free initrd memory if opening /initrd.image fails") Signed-off-by: Steven Price <steven.price@arm.com> Reported-by: Mark Rutland <mark.rutland@arm.com> Tested-by: Mark Rutland <mark.rutland@arm.com> Reviewed-by: Mike Rapoport <rppt@linux.ibm.com> Cc: Christoph Hellwig <hch@lst.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent ec084de commit 5d59aa8

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎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)