]> www.infradead.org Git - users/jedix/linux-maple.git/commit
maple_tree: Add a mas_destroy() call to mas_expected_entries() failure
authorLiam R. Howlett <Liam.Howlett@oracle.com>
Thu, 21 Jul 2022 00:41:04 +0000 (20:41 -0400)
committerLiam R. Howlett <Liam.Howlett@oracle.com>
Fri, 22 Jul 2022 19:09:46 +0000 (15:09 -0400)
commit649c2ab3e9bed3803a3a225bca0afe42b763b699
treee42761bca470e28937c85455b6c82c9578cc88e9
parent0c8c4fcbaa46a249e91c8c8af7bfff1e074d29dd
maple_tree: Add a mas_destroy() call to mas_expected_entries() failure
path

In an exceedingly rare case, there is a possibility that allocating all
of the nodes may fail in a way that the maple state is left with some
allocations completed.  This would happen if the single allocation
succeeds but bulk allocation fails, or if multiple bulk allocations are
required and somewhere along the way one fails.  The partial return is
already cleaned up, but the successful allocations will remain in the
maple state.  When this happens, mas_expected_entries() may leak memory.
Fix this by moving mas_destroy() above mas_expected_entries() and add a
call to mas_destroy() to clear out all allocated memory.

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
lib/maple_tree.c