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: <ZKXFBxUk32hLnueu@localhost.localdomain>
Date: Wed, 5 Jul 2023 21:31:19 +0200
From: Michal Kubiak <michal.kubiak@...el.com>
To: Saeed Mahameed <saeed@...nel.org>
CC: "David S. Miller" <davem@...emloft.net>, Jakub Kicinski <kuba@...nel.org>,
	Paolo Abeni <pabeni@...hat.com>, Eric Dumazet <edumazet@...gle.com>, "Saeed
 Mahameed" <saeedm@...dia.com>, <netdev@...r.kernel.org>, Tariq Toukan
	<tariqt@...dia.com>, Zhengchao Shao <shaozhengchao@...wei.com>, "Rahul
 Rameshbabu" <rrameshbabu@...dia.com>, Gal Pressman <gal@...dia.com>, "Simon
 Horman" <simon.horman@...igine.com>
Subject: Re: [net V2 3/9] net/mlx5e: fix memory leak in mlx5e_ptp_open

On Wed, Jul 05, 2023 at 10:57:51AM -0700, Saeed Mahameed wrote:
> From: Zhengchao Shao <shaozhengchao@...wei.com>
> 
> When kvzalloc_node or kvzalloc failed in mlx5e_ptp_open, the memory
> pointed by "c" or "cparams" is not freed, which can lead to a memory
> leak. Fix by freeing the array in the error path.
> 
> Fixes: 145e5637d941 ("net/mlx5e: Add TX PTP port object support")
> Signed-off-by: Zhengchao Shao <shaozhengchao@...wei.com>
> Reviewed-by: Rahul Rameshbabu <rrameshbabu@...dia.com>
> Reviewed-by: Gal Pressman <gal@...dia.com>
> Reviewed-by: Simon Horman <simon.horman@...igine.com>
> Signed-off-by: Saeed Mahameed <saeedm@...dia.com>
> ---
>  drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c b/drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c
> index 3cbebfba582b..b0b429a0321e 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c
> @@ -729,8 +729,10 @@ int mlx5e_ptp_open(struct mlx5e_priv *priv, struct mlx5e_params *params,
>  
>  	c = kvzalloc_node(sizeof(*c), GFP_KERNEL, dev_to_node(mlx5_core_dma_dev(mdev)));
>  	cparams = kvzalloc(sizeof(*cparams), GFP_KERNEL);
> -	if (!c || !cparams)
> -		return -ENOMEM;
> +	if (!c || !cparams) {
> +		err = -ENOMEM;
> +		goto err_free;
> +	}
>  
>  	c->priv     = priv;
>  	c->mdev     = priv->mdev;
> -- 
> 2.41.0
> 
> 

Looks OK to me.

Thanks,
Reviewed-by: Michal Kubiak <michal.kubiak@...el.com>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ