From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5BE98C4360C for ; Sun, 29 Sep 2019 13:58:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2944821906 for ; Sun, 29 Sep 2019 13:58:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1569765535; bh=uH1HUWuKukDOrWbWpV9nwDLryxXChBQvaLLNDBn2C/c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=MTvMT/xIUa1Vcj95Sdi9pIR0jy0opqLY8RuKELljs7ryztd+GH1cBSEvM+o1tIs9W 5unw8qMRheqJ4g47zna5CH0DIdC1RJ79aPgZ7/r4PMouU5deI3qwMKqSa5hvqROyub khTT7eDIO5fOeDans4EedFf6pskEtfn2AyOy1Qms= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729597AbfI2N6v (ORCPT ); Sun, 29 Sep 2019 09:58:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:39736 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729530AbfI2N6u (ORCPT ); Sun, 29 Sep 2019 09:58:50 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0F2AF21882; Sun, 29 Sep 2019 13:58:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1569765529; bh=uH1HUWuKukDOrWbWpV9nwDLryxXChBQvaLLNDBn2C/c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f4z+vwNdeIM7z3dXwwUPfOHiHfjSMP2JjciCeVE/vmpRA9eVQeYyobfYdNgQNXxQl RFvs+g+F241lil61zr82M9mTG+jU2XfgHSohshGoXJoZLlHP6iOy5t3oh+Mizm4CCa 7XOnxrE4k0VjddOYO4RzfBBozdXNcbKLfYSwglhA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Steven Price , Mark Rutland , Mike Rapoport , Christoph Hellwig , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH 4.19 47/63] initramfs: dont free a non-existent initrd Date: Sun, 29 Sep 2019 15:54:20 +0200 Message-Id: <20190929135039.770549694@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190929135031.382429403@linuxfoundation.org> References: <20190929135031.382429403@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Steven Price [ 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 --- init/initramfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init/initramfs.c b/init/initramfs.c index cd5fb00fcb549..dab8d63459f63 100644 --- a/init/initramfs.c +++ b/init/initramfs.c @@ -524,7 +524,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 -- 2.20.1