]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
lib/test_kasan.c: fix memory leak in kmalloc_oob_krealloc_more()
authorGustavo A. R. Silva <gustavo@embeddedor.com>
Fri, 31 Jan 2020 06:13:51 +0000 (22:13 -0800)
committerKhalid Elmously <khalid.elmously@canonical.com>
Fri, 13 Mar 2020 04:31:00 +0000 (00:31 -0400)
commit4b3669aaa4022718ad60a0e1b36049c4a0b0994a
treef61e2d520aa0c37ff7a52707994e5505930f1f6c
parente5d05e409285457be980ca2cbdd4baa56a34c1ca
lib/test_kasan.c: fix memory leak in kmalloc_oob_krealloc_more()

BugLink: https://bugs.launchpad.net/bugs/1866678
commit 3e21d9a501bf99aee2e5835d7f34d8c823f115b5 upstream.

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")
Link: http://lkml.kernel.org/r/20200123160115.GA4202@embeddedor
Fixes: 3f15801cdc23 ("lib: add kasan test module")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
lib/test_kasan.c