Skip to content

Commit c105e76

Browse files
Dan Carpenterdubeyko
authored andcommitted
hfs: fix potential use after free in hfs_correct_next_unused_CNID()
This code calls hfs_bnode_put(node) which drops the refcount and then dreferences "node" on the next line. It's only safe to use "node" when we're holding a reference so flip these two lines around. Fixes: a06ec28 ("hfs: add logic of correcting a next unused CNID") Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org> Reviewed-by: Viacheslav Dubeyko <slava@dubeyko.com> Signed-off-by: Viacheslav Dubeyko <slava@dubeyko.com> Link: https://lore.kernel.org/r/aN-Xw8KnbSnuIcLk@stanley.mountain Signed-off-by: Viacheslav Dubeyko <slava@dubeyko.com>
1 parent 3a86608 commit c105e76

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

fs/hfs/catalog.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,9 +322,9 @@ int hfs_correct_next_unused_CNID(struct super_block *sb, u32 cnid)
322322
}
323323
}
324324

325+
node_id = node->prev;
325326
hfs_bnode_put(node);
326327

327-
node_id = node->prev;
328328
} while (node_id >= leaf_head);
329329

330330
return -ENOENT;

0 commit comments

Comments
 (0)