From: Christoph Hellwig <hch@infradead.org>
To: Andrew Morton <akpm@osdl.org>
Cc: Pekka Enberg <penberg@cs.helsinki.fi>,
hch@infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/3] freevxfs: fix buffer_head leak
Date: Wed, 29 Jun 2005 08:10:24 +0100 [thread overview]
Message-ID: <20050629071023.GD16850@infradead.org> (raw)
In-Reply-To: <20050628162812.483eb566.akpm@osdl.org>
> Something like this?
>
> diff -puN fs/freevxfs/vxfs_fshead.c~freevxfs-fix-buffer_head-leak fs/freevxfs/vxfs_fshead.c
> --- 25/fs/freevxfs/vxfs_fshead.c~freevxfs-fix-buffer_head-leak Tue Jun 28 16:19:53 2005
> +++ 25-akpm/fs/freevxfs/vxfs_fshead.c Tue Jun 28 16:24:53 2005
> @@ -78,14 +78,16 @@ vxfs_getfsh(struct inode *ip, int which)
> struct buffer_head *bp;
>
> bp = vxfs_bread(ip, which);
> - if (buffer_mapped(bp)) {
> + if (bp && buffer_mapped(bp)) {
> struct vxfs_fsh *fhp;
>
> - if (!(fhp = kmalloc(sizeof(*fhp), SLAB_KERNEL)))
> + if (!(fhp = kmalloc(sizeof(*fhp), GFP_KERNEL))) {
> + put_bh(bp);
> return NULL;
> + }
> memcpy(fhp, bp->b_data, sizeof(*fhp));
>
> - brelse(bp);
> + put_bh(bp);
> return (fhp);
> }
you're still leaking a buffer in the hypothetical !buffer_mapped() case.
Better remove that check completely.
next prev parent reply other threads:[~2005-06-29 7:10 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <iit0gm.lxobpl.5z2b9jduhy9fvx6tjxrco46v4.refire@cs.helsinki.fi>
2005-06-28 23:28 ` [PATCH 1/3] freevxfs: fix buffer_head leak Andrew Morton
2005-06-29 4:25 ` Pekka Enberg
2005-06-29 7:10 ` Christoph Hellwig [this message]
2005-06-29 7:21 ` Andrew Morton
[not found] ` <iit0h1.q7pnex.bkir3xysppdufw6d9h65boz37.refire@cs.helsinki.fi>
2005-06-28 23:31 ` [PATCH 2/3] freevxfs: minor cleanups Andrew Morton
2005-06-29 4:20 ` Pekka Enberg
2005-06-29 7:08 ` Christoph Hellwig
2005-06-29 7:42 ` Pekka J Enberg
2005-06-29 7:50 ` Christoph Hellwig
2005-06-29 7:32 ` [PATCH 2/3] " Matthias Urlichs
2005-06-29 7:58 ` Pekka Enberg
2005-06-29 7:07 ` Christoph Hellwig
2005-06-29 7:17 ` Andrew Morton
2005-06-29 7:21 ` Christoph Hellwig
2005-06-29 7:39 ` Matthias Urlichs
2005-06-29 7:51 ` Pekka J Enberg
2005-06-29 10:23 ` Roman Zippel
[not found] ` <iit0hc.owmgrf.a8mlfisjmja2ab31fpl1ysmkp.refire@cs.helsinki.fi>
2005-06-28 23:33 ` [PATCH 3/3] freevxfs: remove 2.4 compatability Andrew Morton
2005-06-29 7:07 ` Christoph Hellwig
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=20050629071023.GD16850@infradead.org \
--to=hch@infradead.org \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=penberg@cs.helsinki.fi \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.