All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pekka Enberg <penberg@cs.helsinki.fi>
To: Andrew Morton <akpm@osdl.org>
Cc: hch@infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/3] freevxfs: fix buffer_head leak
Date: Wed, 29 Jun 2005 07:25:47 +0300	[thread overview]
Message-ID: <1120019148.9658.9.camel@localhost> (raw)
In-Reply-To: <20050628162812.483eb566.akpm@osdl.org>

On Tue, 2005-06-28 at 16:28 -0700, Andrew Morton wrote:
> But your change means that we'll always perform that kmalloc, even if the
> buffer came back !buffer_mapped().

I think I originally dropped that buffer_mapped() check (which doesn't
make sense to me) which is why I shuffled the code around.

On Tue, 2005-06-28 at 16:28 -0700, Andrew Morton wrote:
> Something like this?

Works for me. Thanks.

> 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);
>  	}
>  
> _
> 


  reply	other threads:[~2005-06-29  4:30 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 [this message]
2005-06-29  7:10   ` Christoph Hellwig
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=1120019148.9658.9.camel@localhost \
    --to=penberg@cs.helsinki.fi \
    --cc=akpm@osdl.org \
    --cc=hch@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    /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.