Re: [PATCH] net: microchip: vcap api: Fix memory leaks in vcap_api_encode_rule_test()

From: Daniel Machon
Date: Fri Oct 11 2024 - 06:26:29 EST


> Cc: stable@xxxxxxxxxxxxxxx
> Fixes: a3c1e45156ad ("net: microchip: vcap: Fix use-after-free error in kunit test")
> Signed-off-by: Jinjie Ruan <ruanjinjie@xxxxxxxxxx>
> ---
> drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c b/drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c
> index f2a5a36fdacd..7251121ab196 100644
> --- a/drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c
> +++ b/drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c
> @@ -1444,6 +1444,8 @@ static void vcap_api_encode_rule_test(struct kunit *test)
>
> ret = vcap_del_rule(&test_vctrl, &test_netdev, id);
> KUNIT_EXPECT_EQ(test, 0, ret);
> +
> + vcap_free_rule(rule);
> }

Wait, should vcap_del_rule not handle the freeing of the rule?
Maybe Emil can shed some light on this..

/Daniel

>
> static void vcap_api_set_rule_counter_test(struct kunit *test)
> --
> 2.34.1
>