提交 9687fd91 编写于 作者: D David Engraf 提交者: Linus Torvalds

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: NDavid Engraf <david.engraf@sysgo.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 d97b07c5
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册