diff options
author | Matthew Wilcox <willy@infradead.org> | 2018-08-18 14:05:50 +0300 |
---|---|---|
committer | Matthew Wilcox <willy@infradead.org> | 2018-08-22 06:49:31 +0300 |
commit | 76f070b4135563165c523ab560056b7a9353e2f2 (patch) | |
tree | 7b4d6288ab637779a59d325f1cc1acaca8b904f9 /lib | |
parent | d1c0d5e3c63d61226a75f24d5c35fe20755f0180 (diff) | |
download | linux-76f070b4135563165c523ab560056b7a9353e2f2.tar.xz |
radix-tree: Fix UBSAN warning
get_slot_offset() can be called with a NULL 'parent' argument.
In this case, the calculated value will not be used, but calculating
it is undefined. Rather than fixing the caller (__radix_tree_delete)
to not call get_slot_offset(), make get_slot_offset() robust against
being called with a NULL parent.
Signed-off-by: Matthew Wilcox <willy@infradead.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/radix-tree.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/radix-tree.c b/lib/radix-tree.c index a9e41aed6de4..cc6096b97afb 100644 --- a/lib/radix-tree.c +++ b/lib/radix-tree.c @@ -120,7 +120,7 @@ bool is_sibling_entry(const struct radix_tree_node *parent, void *node) static inline unsigned long get_slot_offset(const struct radix_tree_node *parent, void __rcu **slot) { - return slot - parent->slots; + return parent ? slot - parent->slots : 0; } static unsigned int radix_tree_descend(const struct radix_tree_node *parent, |