From: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
To: Andre Goddard Rosa <andre.goddard@gmail.com>
Cc: kosaki.motohiro@jp.fujitsu.com,
Andrew Morton <akpm@linux-foundation.org>,
Alexander Viro <viro@zeniv.linux.org.uk>,
Roland McGrath <roland@redhat.com>, WANG Cong <amwang@redhat.com>,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] coredump: plug a memory leak situation on dump_seek()
Date: Tue, 9 Mar 2010 12:08:46 +0900 (JST) [thread overview]
Message-ID: <20100309120706.7CD2.A69D9226@jp.fujitsu.com> (raw)
In-Reply-To: <fe97698815cd081b5ab33a8c25c8b69cd0371a99.1267785456.git.andre.goddard@gmail.com>
> 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>
Looks good.
Thanks, Andre!
- kosaki
> ---
> include/linux/coredump.h | 10 +++++++---
> 1 files changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/include/linux/coredump.h b/include/linux/coredump.h
> index b3c91d7..8ba66a9 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 */
> --
> 1.7.0.1.164.gbe2f
>
next prev parent reply other threads:[~2010-03-09 3:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-05 10:40 [PATCH] coredump: plug a memory leak situation on dump_seek() André Goddard Rosa
2010-03-09 3:08 ` KOSAKI Motohiro [this message]
2010-03-10 9:10 ` Cong Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100309120706.7CD2.A69D9226@jp.fujitsu.com \
--to=kosaki.motohiro@jp.fujitsu.com \
--cc=akpm@linux-foundation.org \
--cc=amwang@redhat.com \
--cc=andre.goddard@gmail.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=roland@redhat.com \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox