[PATCH] freevxfs: fix buffer_head leak
authorPekka Enberg <penberg@cs.helsinki.fi>
Thu, 30 Jun 2005 09:59:04 +0000 (02:59 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Thu, 30 Jun 2005 15:45:12 +0000 (08:45 -0700)
- fix a buffer_head leak in vxfs_getfsh()

- s/SLAB_KERNEL/GFP_KERNEL/

- check sb_bread() return value

- drop pointless buffer-mapped() test.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
fs/freevxfs/vxfs_fshead.c

index 05b19f70bf97efdd47872566e15e6638c41aa1b7..6dee109aeea406d853ea7d3dfc4eea41294d98d2 100644 (file)
@@ -78,17 +78,18 @@ vxfs_getfsh(struct inode *ip, int which)
        struct buffer_head              *bp;
 
        bp = vxfs_bread(ip, which);
-       if (buffer_mapped(bp)) {
+       if (bp) {
                struct vxfs_fsh         *fhp;
 
-               if (!(fhp = kmalloc(sizeof(*fhp), SLAB_KERNEL)))
-                       return NULL;
+               if (!(fhp = kmalloc(sizeof(*fhp), GFP_KERNEL)))
+                       goto out;
                memcpy(fhp, bp->b_data, sizeof(*fhp));
 
-               brelse(bp);
+               put_bh(bp);
                return (fhp);
        }
-
+out:
+       brelse(bp);
        return NULL;
 }