lkml.org 
[lkml]   [2014]   [Jul]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] add error checks to initramfs
On a system with low memory extracting the initramfs may fail. If this 
happens the user gets "Failed to execute /init" instead of an initramfs
error.

Check return value of sys_write and call error() when the write was
incomplete or failed.

Signed-off-by: David Engraf <david.engraf@sysgo.com>

diff --git a/init/initramfs.c b/init/initramfs.c
index a8497fa..64013cc 100644
--- a/init/initramfs.c
+++ b/init/initramfs.c
@@ -346,7 +346,8 @@ static int __init do_name(void)
static int __init do_copy(void)
{
if (count >= body_len) {
- sys_write(wfd, victim, body_len);
+ if (sys_write(wfd, victim, body_len) != body_len)
+ error("write error");
sys_close(wfd);
do_utime(vcollected, mtime);
kfree(vcollected);
@@ -354,7 +355,8 @@ static int __init do_copy(void)
state = SkipIt;
return 0;
} else {
- sys_write(wfd, victim, count);
+ if (sys_write(wfd, victim, count) != count)
+ error("write error");
body_len -= count;
eat(count);
return 1;
\
 
 \ /
  Last update: 2014-07-18 12:01    [W:0.026 / U:0.024 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site