]> 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>
Thu, 21 Jul 2022 00:41:04 +0000 (20:41 -0400)
commit102e6194d01c1605885e330fcb67ed66d08038a5
tree6455986ba2344c73e12f0459f00713ea1c9de27b
parent48387ec1e1de51af42e875bcec8fa96c34316e16
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