aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrĂ© Goddard Rosa <[email protected]>2010-03-10 15:21:22 -0800
committerLinus Torvalds <[email protected]>2010-03-12 15:52:32 -0800
commit6e3e37a5a7c91045497553bcbd6a5faea98b21b3 (patch)
tree10aabb16410477cb65057e96a3bff804423675e2
parent5cacdb4add1b1e50fe75edc50ebbb7bddd9cf5e7 (diff)
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: AndrĂ© Goddard Rosa <[email protected]> Acked-by: KOSAKI Motohiro <[email protected]> Cc: Alexander Viro <[email protected]> Cc: Roland McGrath <[email protected]> Cc: WANG Cong <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
-rw-r--r--include/linux/coredump.h10
1 files changed, 7 insertions, 3 deletions
diff --git a/include/linux/coredump.h b/include/linux/coredump.h
index b3c91d7cede4..8ba66a9d9022 100644
--- a/include/linux/coredump.h
+++ b/include/linux/coredump.h
@@ -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 */