All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] initramfs: cleanup incomplete rootfs
@ 2018-10-22 13:40 David Engraf
  2018-10-30 15:18 ` [PATCH RESEND] " David Engraf
  0 siblings, 1 reply; 15+ messages in thread
From: David Engraf @ 2018-10-22 13:40 UTC (permalink / raw)
  To: linux, akpm, pombredanne, gregkh, arnd, luc.vanoostenryck
  Cc: linux-kernel, David Engraf

Unpacking an external initrd may fail e.g. not enough memory. This leads
to an incomplete rootfs because some files might be extracted already.
Fixed by cleaning the rootfs so the kernel is not using an incomplete
rootfs.

Signed-off-by: David Engraf <david.engraf@sysgo.com>
---
 init/initramfs.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/init/initramfs.c b/init/initramfs.c
index 640557788026..aa3a46cfcb4e 100644
--- a/init/initramfs.c
+++ b/init/initramfs.c
@@ -548,7 +548,6 @@ static void __init free_initrd(void)
 	initrd_end = 0;
 }
 
-#ifdef CONFIG_BLK_DEV_RAM
 #define BUF_SIZE 1024
 static void __init clean_rootfs(void)
 {
@@ -595,7 +594,6 @@ static void __init clean_rootfs(void)
 	ksys_close(fd);
 	kfree(buf);
 }
-#endif
 
 static int __init populate_rootfs(void)
 {
@@ -638,8 +636,10 @@ static int __init populate_rootfs(void)
 		printk(KERN_INFO "Unpacking initramfs...\n");
 		err = unpack_to_rootfs((char *)initrd_start,
 			initrd_end - initrd_start);
-		if (err)
+		if (err) {
 			printk(KERN_EMERG "Initramfs unpacking failed: %s\n", err);
+			clean_rootfs();
+		}
 		free_initrd();
 #endif
 	}
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2019-02-15 20:13 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-22 13:40 [PATCH] initramfs: cleanup incomplete rootfs David Engraf
2018-10-30 15:18 ` [PATCH RESEND] " David Engraf
2019-02-08 19:45   ` Andy Shevchenko
2019-02-08 22:08     ` Andrew Morton
2019-02-09 10:35       ` Andy Shevchenko
2019-02-11  7:56         ` David Engraf
2019-02-11  8:49           ` David Engraf
2019-02-11 11:40             ` Andy Shevchenko
2019-02-11 12:40               ` David Engraf
2019-02-12 10:43                 ` Andy Shevchenko
2019-02-12 12:12                   ` David Engraf
2019-02-12 13:50                     ` Andy Shevchenko
2019-02-15 20:13                       ` Andy Shevchenko
2019-02-12  0:56         ` Andrew Morton
2019-02-12  8:04           ` David Engraf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.