aboutsummaryrefslogtreecommitdiffstats
path: root/fs/hfsplus/dir.c
diff options
context:
space:
mode:
authorAlexey Khoroshilov <khoroshilov@ispras.ru>2011-07-05 18:29:59 -0400
committerChristoph Hellwig <hch@lst.de>2011-07-07 11:45:46 -0400
commit5bd9d99d107c56ff7b35a29e930d85f91a07b2fd (patch)
treeb5db237ebff38c90b95f01d8cca28bc8c2536e7f /fs/hfsplus/dir.c
parentc6d5f5fa658f2569a7baaff5acda261a1316cee9 (diff)
hfsplus: add error checking for hfs_find_init()
hfs_find_init() may fail with ENOMEM, but there are places, where the returned value is not checked. The consequences can be very unpleasant, e.g. kfree uninitialized pointer and inappropriate mutex unlocking. The patch adds checks for errors in hfs_find_init(). Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru> Signed-off-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'fs/hfsplus/dir.c')
-rw-r--r--fs/hfsplus/dir.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/fs/hfsplus/dir.c b/fs/hfsplus/dir.c
index 4df5059c25da..25b2443a004c 100644
--- a/fs/hfsplus/dir.c
+++ b/fs/hfsplus/dir.c
@@ -38,7 +38,9 @@ static struct dentry *hfsplus_lookup(struct inode *dir, struct dentry *dentry,
38 sb = dir->i_sb; 38 sb = dir->i_sb;
39 39
40 dentry->d_fsdata = NULL; 40 dentry->d_fsdata = NULL;
41 hfs_find_init(HFSPLUS_SB(sb)->cat_tree, &fd); 41 err = hfs_find_init(HFSPLUS_SB(sb)->cat_tree, &fd);
42 if (err)
43 return ERR_PTR(err);
42 hfsplus_cat_build_key(sb, fd.search_key, dir->i_ino, &dentry->d_name); 44 hfsplus_cat_build_key(sb, fd.search_key, dir->i_ino, &dentry->d_name);
43again: 45again:
44 err = hfs_brec_read(&fd, &entry, sizeof(entry)); 46 err = hfs_brec_read(&fd, &entry, sizeof(entry));
@@ -132,7 +134,9 @@ static int hfsplus_readdir(struct file *filp, void *dirent, filldir_t filldir)
132 if (filp->f_pos >= inode->i_size) 134 if (filp->f_pos >= inode->i_size)
133 return 0; 135 return 0;
134 136
135 hfs_find_init(HFSPLUS_SB(sb)->cat_tree, &fd); 137 err = hfs_find_init(HFSPLUS_SB(sb)->cat_tree, &fd);
138 if (err)
139 return err;
136 hfsplus_cat_build_key(sb, fd.search_key, inode->i_ino, NULL); 140 hfsplus_cat_build_key(sb, fd.search_key, inode->i_ino, NULL);
137 err = hfs_brec_find(&fd); 141 err = hfs_brec_find(&fd);
138 if (err) 142 if (err)