Skip to content
Commit 98d726f8 authored by Steven Price's avatar Steven Price Committed by Paul Gortmaker
Browse files

initramfs: don't free a non-existent initrd

commit 5d59aa8f upstream.

Since commit 54c7a891 ("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: 54c7a891 ("initramfs: free initrd memory if opening /initrd.image fails")
Signed-off-by: default avatarSteven Price <steven.price@arm.com>
Reported-by: default avatarMark Rutland <mark.rutland@arm.com>
Tested-by: default avatarMark Rutland <mark.rutland@arm.com>
Reviewed-by: default avatarMike Rapoport <rppt@linux.ibm.com>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
[PG: adapt for older 4.18.x codebase with kexec if/else chunk.]
Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
parent 499b8347
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment