| From: Liam Howlett <liam.howlett@oracle.com> |
| Subject: maple_tree: make mas_prealloc() error checking more generic |
| Date: Wed, 15 Jun 2022 17:42:20 +0000 |
| |
| Return the error regardless of what it is. This is a safer option. |
| |
| Link: https://lkml.kernel.org/r/20220615174213.738849-1-Liam.Howlett@oracle.com |
| Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com> |
| Signed-off-by: Andrew Morton <akpm@linux-foundation.org> |
| --- |
| |
| lib/maple_tree.c | 5 ++--- |
| 1 file changed, 2 insertions(+), 3 deletions(-) |
| |
| --- a/lib/maple_tree.c~maple-tree-add-new-data-structure-fix-9 |
| +++ a/lib/maple_tree.c |
| @@ -5654,16 +5654,15 @@ void mas_store_prealloc(struct ma_state |
| */ |
| int mas_preallocate(struct ma_state *mas, void *entry, gfp_t gfp) |
| { |
| - |
| mas_set_alloc_req(mas, 1 + mas_mt_height(mas) * 3); |
| mas_alloc_nodes(mas, gfp); |
| - if (likely(mas->node != MA_ERROR(-ENOMEM))) |
| + if (likely(!mas_is_err(mas))) |
| return 0; |
| |
| mas_set_alloc_req(mas, 0); |
| mas_destroy(mas); |
| mas->node = MAS_START; |
| - return -ENOMEM; |
| + return xa_err(mas->node); |
| } |
| |
| /* |
| _ |