Skip to content
This repository has been archived by the owner on Sep 18, 2022. It is now read-only.

Commit

Permalink
coredump: plug a memory leak situation on dump_seek()
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
andre-rosa authored and torvalds committed Mar 12, 2010
1 parent 5cacdb4 commit 6e3e37a
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions include/linux/coredump.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 */

0 comments on commit 6e3e37a

Please sign in to comment.