aboutsummaryrefslogtreecommitdiffstats
path: root/fs/hfsplus/inode.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/inode.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/inode.c')
-rw-r--r--fs/hfsplus/inode.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c
index b248a6cfcad9..010cd363d085 100644
--- a/fs/hfsplus/inode.c
+++ b/fs/hfsplus/inode.c
@@ -195,11 +195,13 @@ static struct dentry *hfsplus_file_lookup(struct inode *dir,
195 hip->flags = 0; 195 hip->flags = 0;
196 set_bit(HFSPLUS_I_RSRC, &hip->flags); 196 set_bit(HFSPLUS_I_RSRC, &hip->flags);
197 197
198 hfs_find_init(HFSPLUS_SB(sb)->cat_tree, &fd); 198 err = hfs_find_init(HFSPLUS_SB(sb)->cat_tree, &fd);
199 err = hfsplus_find_cat(sb, dir->i_ino, &fd); 199 if (!err) {
200 if (!err) 200 err = hfsplus_find_cat(sb, dir->i_ino, &fd);
201 err = hfsplus_cat_read_inode(inode, &fd); 201 if (!err)
202 hfs_find_exit(&fd); 202 err = hfsplus_cat_read_inode(inode, &fd);
203 hfs_find_exit(&fd);
204 }
203 if (err) { 205 if (err) {
204 iput(inode); 206 iput(inode);
205 return ERR_PTR(err); 207 return ERR_PTR(err);