lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Y4yYzlzPKix6VloH@unreal>
Date:   Sun, 4 Dec 2022 14:55:42 +0200
From:   Leon Romanovsky <leon@...nel.org>
To:     Ziyang Xuan <william.xuanziyang@...wei.com>
Cc:     sgoutham@...vell.com, gakula@...vell.com, sbhatta@...vell.com,
        hkelam@...vell.com, davem@...emloft.net, edumazet@...gle.com,
        kuba@...nel.org, pabeni@...hat.com, netdev@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH net v2] octeontx2-pf: Fix potential memory leak in
 otx2_init_tc()

On Fri, Dec 02, 2022 at 07:04:30PM +0800, Ziyang Xuan wrote:
> In otx2_init_tc(), if rhashtable_init() failed, it does not free
> tc->tc_entries_bitmap which is allocated in otx2_tc_alloc_ent_bitmap().
> 
> Fixes: 2e2a8126ffac ("octeontx2-pf: Unify flow management variables")
> Signed-off-by: Ziyang Xuan <william.xuanziyang@...wei.com>
> ---
> v2:
>   - Remove patch 2 which is not a problem, see the following link:
>     https://www.spinics.net/lists/netdev/msg864159.html
> ---
>  drivers/net/ethernet/marvell/octeontx2/nic/otx2_tc.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_tc.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_tc.c
> index e64318c110fd..6a01ab1a6e6f 100644
> --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_tc.c
> +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_tc.c
> @@ -1134,7 +1134,12 @@ int otx2_init_tc(struct otx2_nic *nic)
>  		return err;
>  
>  	tc->flow_ht_params = tc_flow_ht_params;
> -	return rhashtable_init(&tc->flow_table, &tc->flow_ht_params);
> +	err = rhashtable_init(&tc->flow_table, &tc->flow_ht_params);
> +	if (err) {
> +		kfree(tc->tc_entries_bitmap);
> +		tc->tc_entries_bitmap = NULL;

Why do you set NULL here? All callers of otx2_init_tc() unwind error
properly.

> +	}
> +	return err;
>  }
>  EXPORT_SYMBOL(otx2_init_tc);
>  
> -- 
> 2.25.1
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ