lkml.org 
[lkml]   [2005]   [Jun]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/3] freevxfs: fix buffer_head leak
> 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.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-06-29 09:16    [W:0.055 / U:0.336 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site