From: Steven Price Date: Fri, 17 May 2019 21:31:47 +0000 (-0700) Subject: initramfs: don't free a non-existent initrd X-Git-Tag: Ubuntu-4.15.0-67.76~130 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=ddd4dbf420c8c023648495250d093c06633ea839;p=mirror_ubuntu-bionic-kernel.git initramfs: don't free a non-existent initrd BugLink: https://bugs.launchpad.net/bugs/1847155 [ Upstream commit 5d59aa8f9ce972b472201aed86e904bb75879ff0 ] Since commit 54c7a8916a88 ("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: 54c7a8916a88 ("initramfs: free initrd memory if opening /initrd.image fails") Signed-off-by: Steven Price Reported-by: Mark Rutland Tested-by: Mark Rutland Reviewed-by: Mike Rapoport Cc: Christoph Hellwig Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin Signed-off-by: Kamal Mostafa Signed-off-by: Kleber Sacilotto de Souza --- diff --git a/init/initramfs.c b/init/initramfs.c index 4be1b65b0676..ffcccf01e77e 100644 --- a/init/initramfs.c +++ b/init/initramfs.c @@ -532,7 +532,7 @@ static void __init free_initrd(void) unsigned long crashk_start = (unsigned long)__va(crashk_res.start); unsigned long crashk_end = (unsigned long)__va(crashk_res.end); #endif - if (do_retain_initrd) + if (do_retain_initrd || !initrd_start) goto skip; #ifdef CONFIG_KEXEC_CORE