Skip to content

Commit dc25727

Browse files
eafertorvalds
authored andcommitted
hfs: prevent crash on exit from failed search
hfs_find_exit() expects fd->bnode to be NULL after a search has failed. hfs_brec_insert() may instead set it to an error-valued pointer. Fix this to prevent a crash. Link: http://lkml.kernel.org/r/53d9749a029c41b4016c495fc5838c9dba3afc52.1530294815.git.ernesto.mnd.fernandez@gmail.com Signed-off-by: Ernesto A. Fernández <ernesto.mnd.fernandez@gmail.com> Cc: Anatoly Trosinenko <anatoly.trosinenko@gmail.com> Cc: Viacheslav Dubeyko <slava@dubeyko.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent aba93a9 commit dc25727

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

‎fs/hfs/brec.c‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,10 @@ int hfs_brec_insert(struct hfs_find_data *fd, void *entry, int entry_len)
7575
if (!fd->bnode) {
7676
if (!tree->root)
7777
hfs_btree_inc_height(tree);
78-
fd->bnode = hfs_bnode_find(tree, tree->leaf_head);
79-
if (IS_ERR(fd->bnode))
80-
return PTR_ERR(fd->bnode);
78+
node = hfs_bnode_find(tree, tree->leaf_head);
79+
if (IS_ERR(node))
80+
return PTR_ERR(node);
81+
fd->bnode = node;
8182
fd->record = -1;
8283
}
8384
new_node = NULL;

0 commit comments

Comments
 (0)