[PATCH] freevxfs: fix buffer_head leak

- 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>

authored by Pekka Enberg and committed by Linus Torvalds ba03bda8 f220ab2a

+6 -5
+6 -5
fs/freevxfs/vxfs_fshead.c
··· 78 struct buffer_head *bp; 79 80 bp = vxfs_bread(ip, which); 81 - if (buffer_mapped(bp)) { 82 struct vxfs_fsh *fhp; 83 84 - if (!(fhp = kmalloc(sizeof(*fhp), SLAB_KERNEL))) 85 - return NULL; 86 memcpy(fhp, bp->b_data, sizeof(*fhp)); 87 88 - brelse(bp); 89 return (fhp); 90 } 91 - 92 return NULL; 93 } 94
··· 78 struct buffer_head *bp; 79 80 bp = vxfs_bread(ip, which); 81 + if (bp) { 82 struct vxfs_fsh *fhp; 83 84 + if (!(fhp = kmalloc(sizeof(*fhp), GFP_KERNEL))) 85 + goto out; 86 memcpy(fhp, bp->b_data, sizeof(*fhp)); 87 88 + put_bh(bp); 89 return (fhp); 90 } 91 + out: 92 + brelse(bp); 93 return NULL; 94 } 95