summaryrefslogtreecommitdiffstats
path: root/init/initramfs.c
diff options
context:
space:
mode:
authorDavid Engraf <david.engraf@sysgo.com>2014-08-08 14:23:16 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2014-08-08 15:57:26 -0700
commit9687fd9101afaa1c4b1de7ffd2f9d7e53f45b29f (patch)
tree97b93d548e3f0c288a3191038f8181ec8bf07bf7 /init/initramfs.c
parentd97b07c54f34e88352ebe676beb798c8f59ac588 (diff)
downloadlinux-9687fd9101afaa1c4b1de7ffd2f9d7e53f45b29f.tar.gz
linux-9687fd9101afaa1c4b1de7ffd2f9d7e53f45b29f.tar.bz2
linux-9687fd9101afaa1c4b1de7ffd2f9d7e53f45b29f.zip
initramfs: add write error checks
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> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'init/initramfs.c')
-rw-r--r--init/initramfs.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/init/initramfs.c b/init/initramfs.c
index a7566031242e..bece48c3461e 100644
--- a/init/initramfs.c
+++ b/init/initramfs.c
@@ -369,7 +369,8 @@ static int __init do_name(void)
static int __init do_copy(void)
{
if (count >= body_len) {
- xwrite(wfd, victim, body_len);
+ if (xwrite(wfd, victim, body_len) != body_len)
+ error("write error");
sys_close(wfd);
do_utime(vcollected, mtime);
kfree(vcollected);
@@ -377,7 +378,8 @@ static int __init do_copy(void)
state = SkipIt;
return 0;
} else {
- xwrite(wfd, victim, count);
+ if (xwrite(wfd, victim, count) != count)
+ error("write error");
body_len -= count;
eat(count);
return 1;