提交 6e3e37a5 编写于 作者: A André Goddard Rosa 提交者: Linus Torvalds

coredump: plug a memory leak situation on dump_seek()

After having started writing the coredump, if filesystem reports an error
anytime while writing part of the core file, we would leak a memory page
when bailing out.
Signed-off-by: NAndré Goddard Rosa <andre.goddard@gmail.com>
Acked-by: NKOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Roland McGrath <roland@redhat.com>
Cc: WANG Cong <amwang@redhat.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 5cacdb4a
......@@ -16,6 +16,8 @@ static inline int dump_write(struct file *file, const void *addr, int nr)
static inline int dump_seek(struct file *file, loff_t off)
{
int ret = 1;
if (file->f_op->llseek && file->f_op->llseek != no_llseek) {
if (file->f_op->llseek(file, off, SEEK_CUR) < 0)
return 0;
......@@ -29,13 +31,15 @@ static inline int dump_seek(struct file *file, loff_t off)
if (n > PAGE_SIZE)
n = PAGE_SIZE;
if (!dump_write(file, buf, n))
return 0;
if (!dump_write(file, buf, n)) {
ret = 0;
break;
}
off -= n;
}
free_page((unsigned long)buf);
}
return 1;
return ret;
}
#endif /* _LINUX_COREDUMP_H */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册