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: <43b3ad78-3f79-468e-9943-941b7498ad90@intel.com>
Date: Wed, 16 Apr 2025 13:08:41 -0700
From: Jacob Keller <jacob.e.keller@...el.com>
To: Abdun Nihaal <abdun.nihaal@...il.com>, <bharat@...lsio.com>
CC: <horms@...nel.org>, <Markus.Elfring@....de>, <andrew+netdev@...n.ch>,
	<davem@...emloft.net>, <edumazet@...gle.com>, <kuba@...nel.org>,
	<pabeni@...hat.com>, <rahul.lakkireddy@...lsio.com>, <vishal@...lsio.com>,
	<netdev@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2 net] cxgb4: fix memory leak in
 cxgb4_init_ethtool_filters() error path



On 4/14/2025 10:06 AM, Abdun Nihaal wrote:
> In the for loop used to allocate the loc_array and bmap for each port, a
> memory leak is possible when the allocation for loc_array succeeds,
> but the allocation for bmap fails. This is because when the control flow
> goes to the label free_eth_finfo, only the allocations starting from
> (i-1)th iteration are freed.
> 
> Fix that by freeing the loc_array in the bmap allocation error path.
> 
> Fixes: d915c299f1da ("cxgb4: add skeleton for ethtool n-tuple filters")
> Signed-off-by: Abdun Nihaal <abdun.nihaal@...il.com>
> Reviewed-by: Simon Horman <horms@...nel.org>
> ---
> v1 -> v2:
> - Added the Reviewed-by tag from Simon Horman
> - Also set the branch target as net instead of net-next as it is a fix
> 
> v1 link: https://patchwork.kernel.org/project/netdevbpf/patch/20250409054323.48557-1-abdun.nihaal@gmail.com/
> 
>  drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c
> index 7f3f5afa864f..1546c3db08f0 100644
> --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c
> +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c
> @@ -2270,6 +2270,7 @@ int cxgb4_init_ethtool_filters(struct adapter *adap)
>  		eth_filter->port[i].bmap = bitmap_zalloc(nentries, GFP_KERNEL);
>  		if (!eth_filter->port[i].bmap) {
>  			ret = -ENOMEM;
> +			kvfree(eth_filter->port[i].loc_array);
>  			goto free_eth_finfo;
>  		}
>  	}


Reviewed-by: Jacob Keller <jacob.e.keller@...el.com>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ