summaryrefslogtreecommitdiff
path: root/fs/ext2
diff options
context:
space:
mode:
authorGlauber de Oliveira Costa <glommer@br.ibm.com>2005-10-31 02:03:05 +0300
committerLinus Torvalds <torvalds@g5.osdl.org>2005-10-31 04:37:26 +0300
commit2973dfdb877c17b36c27ba66d71028ff1eb2f32e (patch)
tree9734599068f3fcf7cd33f948235588f7a275d193 /fs/ext2
parent7f04c26d715a2467a49a2384268de8f70f787b51 (diff)
downloadlinux-2973dfdb877c17b36c27ba66d71028ff1eb2f32e.tar.xz
[PATCH] Test for sb_getblk return value
This patch adds tests for the return value of sb_getblk() in the ext2/3 filesystems. In fs/buffer.c it is stated that the getblk() function never fails. However, it does can return NULL in some situations due to I/O errors, which may lead us to NULL pointer dereferences Signed-off-by: Glauber de Oliveira Costa <glommer@br.ibm.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs/ext2')
-rw-r--r--fs/ext2/inode.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c
index fdba4d1d3c60..e7d3f0522d01 100644
--- a/fs/ext2/inode.c
+++ b/fs/ext2/inode.c
@@ -440,6 +440,10 @@ static int ext2_alloc_branch(struct inode *inode,
* the pointer to new one, then send parent to disk.
*/
bh = sb_getblk(inode->i_sb, parent);
+ if (!bh) {
+ err = -EIO;
+ break;
+ }
lock_buffer(bh);
memset(bh->b_data, 0, blocksize);
branch[n].bh = bh;