Messages in this thread Patch in this message | | | Date | Thu, 23 Jan 2020 10:01:15 -0600 | From | "Gustavo A. R. Silva" <> | Subject | [PATCH] lib/test_kasan.c: Fix memory leak in kmalloc_oob_krealloc_more() |
| |
In case memory resources for _ptr2_ were allocated, release them before return.
Notice that in case _ptr1_ happens to be NULL, krealloc() behaves exactly like kmalloc().
Addresses-Coverity-ID: 1490594 ("Resource leak") Fixes: 3f15801cdc23 ("lib: add kasan test module") Cc: stable@vger.kernel.org Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com> --- lib/test_kasan.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/lib/test_kasan.c b/lib/test_kasan.c index 328d33beae36..3872d250ed2c 100644 --- a/lib/test_kasan.c +++ b/lib/test_kasan.c @@ -158,6 +158,7 @@ static noinline void __init kmalloc_oob_krealloc_more(void) if (!ptr1 || !ptr2) { pr_err("Allocation failed\n"); kfree(ptr1); + kfree(ptr2); return; } -- 2.25.0
| |