aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorAndré Goddard Rosa <andre.goddard@gmail.com>2010-03-10 18:21:22 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2010-03-12 18:52:32 -0500
commit6e3e37a5a7c91045497553bcbd6a5faea98b21b3 (patch)
tree10aabb16410477cb65057e96a3bff804423675e2 /include
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 <andre.goddard@gmail.com> Acked-by: KOSAKI 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: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include')
-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)
16 16
17static inline int dump_seek(struct file *file, loff_t off) 17static inline int dump_seek(struct file *file, loff_t off)
18{ 18{
19 int ret = 1;
20
19 if (file->f_op->llseek && file->f_op->llseek != no_llseek) { 21 if (file->f_op->llseek && file->f_op->llseek != no_llseek) {
20 if (file->f_op->llseek(file, off, SEEK_CUR) < 0) 22 if (file->f_op->llseek(file, off, SEEK_CUR) < 0)
21 return 0; 23 return 0;
@@ -29,13 +31,15 @@ static inline int dump_seek(struct file *file, loff_t off)
29 31
30 if (n > PAGE_SIZE) 32 if (n > PAGE_SIZE)
31 n = PAGE_SIZE; 33 n = PAGE_SIZE;
32 if (!dump_write(file, buf, n)) 34 if (!dump_write(file, buf, n)) {
33 return 0; 35 ret = 0;
36 break;
37 }
34 off -= n; 38 off -= n;
35 } 39 }
36 free_page((unsigned long)buf); 40 free_page((unsigned long)buf);
37 } 41 }
38 return 1; 42 return ret;
39} 43}
40 44
41#endif /* _LINUX_COREDUMP_H */ 45#endif /* _LINUX_COREDUMP_H */