Re: [PATCH] net: microchip: vcap api: Fix memory leaks in vcap_api_encode_rule_test()
From: Simon Horman
Date: Fri Oct 11 2024 - 05:25:04 EST
On Thu, Oct 10, 2024 at 09:02:31PM +0800, Jinjie Ruan wrote:
> Commit a3c1e45156ad ("net: microchip: vcap: Fix use-after-free error in
> kunit test") fixed the use-after-free error, but introduced below
> memory leaks by removing necessary vcap_free_rule(), add it to fix it.
>
> unreferenced object 0xffffff80ca58b700 (size 192):
> comm "kunit_try_catch", pid 1215, jiffies 4294898264
> hex dump (first 32 bytes):
> 00 12 7a 00 05 00 00 00 0a 00 00 00 64 00 00 00 ..z.........d...
> 00 00 00 00 00 00 00 00 00 04 0b cc 80 ff ff ff ................
> backtrace (crc 9c09c3fe):
> [<0000000052a0be73>] kmemleak_alloc+0x34/0x40
> [<0000000043605459>] __kmalloc_cache_noprof+0x26c/0x2f4
> [<0000000040a01b8d>] vcap_alloc_rule+0x3cc/0x9c4
> [<000000003fe86110>] vcap_api_encode_rule_test+0x1ac/0x16b0
> [<00000000b3595fc4>] kunit_try_run_case+0x13c/0x3ac
> [<0000000010f5d2bf>] kunit_generic_run_threadfn_adapter+0x80/0xec
> [<00000000c5d82c9a>] kthread+0x2e8/0x374
> [<00000000f4287308>] ret_from_fork+0x10/0x20
I guess that the rest of the log could be trimmed from the
commit message. But I don't feel strongly about that.
Also, it is probably not necessary to repost just because of this,
but as a bug fix this patch should be targeted at the net tree
and that should be indicated in the subject.
[PATCH net] ...
...
> Cc: stable@xxxxxxxxxxxxxxx
> Fixes: a3c1e45156ad ("net: microchip: vcap: Fix use-after-free error in kunit test")
> Signed-off-by: Jinjie Ruan <ruanjinjie@xxxxxxxxxx>
Reviewed-by: Simon Horman <horms@xxxxxxxxxx>