]> git.baikalelectronics.ru Git - kernel.git/commit
initramfs: don't free a non-existent initrd
authorSteven Price <steven.price@arm.com>
Fri, 17 May 2019 21:31:47 +0000 (14:31 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sat, 18 May 2019 22:52:26 +0000 (15:52 -0700)
commit366576bf00474b160a1c3d342b0578f08fcc402e
tree4584b44a49d089b3a991a0f0a2d25f01b8cc2a95
parent2d47c80c6dfc8072a833ca3b4133ae632570c781
initramfs: don't free a non-existent initrd

Since commit b7377f652c5b ("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: b7377f652c5b ("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>
init/initramfs.c