From: Liam R. Howlett Date: Thu, 1 Sep 2022 20:27:51 +0000 (-0400) Subject: maple_tree: Return error on mas_store_prealloc() X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=56283ced84028d429be20b11024cde854d1a1d26;p=users%2Fjedix%2Flinux-maple.git maple_tree: Return error on mas_store_prealloc() mas_store_prealloc() should never fail, but if it does due to internal tree issues then return the error message and WARN_ON(). Signed-off-by: Liam R. Howlett --- diff --git a/include/linux/maple_tree.h b/include/linux/maple_tree.h index ff6f2e1f1355..3f76b996dda8 100644 --- a/include/linux/maple_tree.h +++ b/include/linux/maple_tree.h @@ -454,7 +454,7 @@ void *mas_walk(struct ma_state *mas); void *mas_store(struct ma_state *mas, void *entry); void *mas_erase(struct ma_state *mas); int mas_store_gfp(struct ma_state *mas, void *entry, gfp_t gfp); -void mas_store_prealloc(struct ma_state *mas, void *entry); +int mas_store_prealloc(struct ma_state *mas, void *entry); void *mas_find(struct ma_state *mas, unsigned long max); void *mas_find_rev(struct ma_state *mas, unsigned long min); int mas_preallocate(struct ma_state *mas, void *entry, gfp_t gfp); diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 05feed59570c..f7273b30cf23 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -5792,16 +5792,24 @@ EXPORT_SYMBOL_GPL(mas_store_gfp); * preallocated in the maple state. * @mas: The maple state * @entry: The entry to store. + * + * If this does not succeed, something went very wrong. + * + * Return: 0 on success */ -void mas_store_prealloc(struct ma_state *mas, void *entry) +int mas_store_prealloc(struct ma_state *mas, void *entry) { MA_WR_STATE(wr_mas, mas, entry); + int ret = 0; mas_wr_store_setup(&wr_mas); trace_ma_write(__func__, mas, 0, entry); mas_wr_store_entry(&wr_mas); - BUG_ON(mas_is_err(mas)); + if(MT_WARN_ON(mas->tree, mas_is_err(mas))) + ret = xa_err(mas->node); + mas_destroy(mas); + return ret; } EXPORT_SYMBOL_GPL(mas_store_prealloc);