[PATCH net 2/5] net: microchip: sparx5: Fix memory leak for vcap_api_rule_add_actionvalue_test()

Daniel Machon daniel.machon at microchip.com
Fri Sep 8 04:29:33 PDT 2023


> Inject fault while probing kunit-example-test.ko, the field which
> is allocated by kzalloc in vcap_rule_add_action() of
> vcap_rule_add_action_bit/u32() is not freed, and it cause
> the memory leaks below.
> 
> Fixes: c956b9b318d9 ("net: microchip: sparx5: Adding KUNIT tests of key/action values in VCAP API")
> Signed-off-by: Jinjie Ruan <ruanjinjie at huawei.com>
> ---
>  .../net/ethernet/microchip/vcap/vcap_api_kunit.c  | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c b/drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c
> index 2fb0b8cf2b0c..aa79bcf3efc2 100644
> --- a/drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c
> +++ b/drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c
> @@ -1095,6 +1095,16 @@ static void vcap_api_rule_add_keyvalue_test(struct kunit *test)
>         vcap_free_ckf(rule);
>  }
> 
> +static void vcap_free_caf(struct vcap_rule *rule)
> +{
> +       struct vcap_client_actionfield *caf, *next_caf;
> +
> +       list_for_each_entry_safe(caf, next_caf, &rule->actionfields, ctrl.list) {
> +               list_del(&caf->ctrl.list);
> +               kfree(caf);
> +       }
> +}
> +

Hi Jinjie,

It seems like you need to respin anyway, so could you please fix this
patch to adhere to the 80 character limit. Checkpatch generates a
warning.

/Daniel




More information about the linux-arm-kernel mailing list