From: Steven Price <steven.price@arm.com>
To: Christoph Hellwig <hch@lst.de>,
Andrew Morton <akpm@linux-foundation.org>
Cc: linux-arch@vger.kernel.org,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will.deacon@arm.com>,
Russell King <linux@armlinux.org.uk>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
Alexander Viro <viro@zeniv.linux.org.uk>,
Guan Xuetao <gxt@pku.edu.cn>,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 2/8] initramfs: free initrd memory if opening /initrd.image fails
Date: Thu, 14 Feb 2019 13:51:51 +0000 [thread overview]
Message-ID: <e4246b25-628e-de5e-56ba-8d45ad9c9fa6@arm.com> (raw)
Message-ID: <20190214135151.rl08gSlb3p82bdycZvxH9MpS_QC2JQlCFUo0XIDLCLs@z> (raw)
In-Reply-To: <20190213174621.29297-3-hch@lst.de>
On 13/02/2019 17:46, Christoph Hellwig wrote:
> We free the initrd memory for all successful or error cases except
> for the case where opening /initrd.image fails, which looks like an
> oversight.
This also changes the behaviour when CONFIG_INITRAMFS_FORCE is enabled -
specifically it means that the initrd is freed (previously it was
ignored and never freed). But that seems like reasonable behaviour and
the previous behaviour looks like another oversight. FWIW:
Reviewed-by: Steven Price <steven.price@arm.com>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> init/initramfs.c | 14 ++++++--------
> 1 file changed, 6 insertions(+), 8 deletions(-)
>
> diff --git a/init/initramfs.c b/init/initramfs.c
> index 7cea802d00ef..1cba6bbeeb75 100644
> --- a/init/initramfs.c
> +++ b/init/initramfs.c
> @@ -610,13 +610,12 @@ static int __init populate_rootfs(void)
> printk(KERN_INFO "Trying to unpack rootfs image as initramfs...\n");
> err = unpack_to_rootfs((char *)initrd_start,
> initrd_end - initrd_start);
> - if (!err) {
> - free_initrd();
> + if (!err)
> goto done;
> - } else {
> - clean_rootfs();
> - unpack_to_rootfs(__initramfs_start, __initramfs_size);
> - }
> +
> + clean_rootfs();
> + unpack_to_rootfs(__initramfs_start, __initramfs_size);
> +
> printk(KERN_INFO "rootfs image is not initramfs (%s)"
> "; looks like an initrd\n", err);
> fd = ksys_open("/initrd.image",
> @@ -630,7 +629,6 @@ static int __init populate_rootfs(void)
> written, initrd_end - initrd_start);
>
> ksys_close(fd);
> - free_initrd();
> }
> done:
> /* empty statement */;
> @@ -642,9 +640,9 @@ static int __init populate_rootfs(void)
> printk(KERN_EMERG "Initramfs unpacking failed: %s\n", err);
> clean_rootfs();
> }
> - free_initrd();
> #endif
> }
> + free_initrd();
> flush_delayed_fput();
> return 0;
> }
>
next prev parent reply other threads:[~2019-02-14 13:51 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-13 17:46 initramfs tidyups Christoph Hellwig
2019-02-13 17:46 ` Christoph Hellwig
2019-02-13 17:46 ` [PATCH 1/8] mm: unexport free_reserved_area Christoph Hellwig
2019-02-13 17:46 ` Christoph Hellwig
2019-02-13 17:46 ` [PATCH 2/8] initramfs: free initrd memory if opening /initrd.image fails Christoph Hellwig
2019-02-13 17:46 ` Christoph Hellwig
2019-02-14 13:51 ` Steven Price [this message]
2019-02-14 13:51 ` Steven Price
2019-02-13 17:46 ` [PATCH 3/8] initramfs: cleanup initrd freeing Christoph Hellwig
2019-02-13 17:46 ` Christoph Hellwig
2019-02-13 17:46 ` [PATCH 4/8] initramfs: factor out a helper to populate the initrd image Christoph Hellwig
2019-02-13 17:46 ` Christoph Hellwig
2019-02-13 17:46 ` [PATCH 5/8] initramfs: cleanup populate_rootfs Christoph Hellwig
2019-02-13 17:46 ` Christoph Hellwig
2019-02-13 17:46 ` [PATCH 6/8] initramfs: move the legacy keepinitrd parameter to core code Christoph Hellwig
2019-02-13 17:46 ` Christoph Hellwig
2019-02-14 16:56 ` Catalin Marinas
2019-02-14 16:56 ` Catalin Marinas
2019-02-13 17:46 ` [PATCH 7/8] initramfs: proide a generic free_initrd_mem implementation Christoph Hellwig
2019-02-13 17:46 ` Christoph Hellwig
2019-02-13 18:41 ` Mike Rapoport
2019-02-13 18:41 ` Mike Rapoport
2019-02-13 18:44 ` Christoph Hellwig
2019-02-13 18:44 ` Christoph Hellwig
2019-02-13 21:41 ` Mike Rapoport
2019-02-13 21:41 ` Mike Rapoport
2019-02-14 8:03 ` Geert Uytterhoeven
2019-02-14 8:03 ` Geert Uytterhoeven
2019-02-14 16:20 ` Mike Rapoport
2019-02-14 16:20 ` Mike Rapoport
2019-02-13 17:46 ` [PATCH 8/8] initramfs: poison freed initrd memory Christoph Hellwig
2019-02-13 17:46 ` Christoph Hellwig
2019-02-13 21:54 ` initramfs tidyups Mike Rapoport
2019-02-13 21:54 ` Mike Rapoport
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e4246b25-628e-de5e-56ba-8d45ad9c9fa6@arm.com \
--to=steven.price@arm.com \
--cc=akpm@linux-foundation.org \
--cc=catalin.marinas@arm.com \
--cc=gxt@pku.edu.cn \
--cc=hch@lst.de \
--cc=linux-arch@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux@armlinux.org.uk \
--cc=viro@zeniv.linux.org.uk \
--cc=will.deacon@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).