Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
From: Tariq Toukan <ttoukan.linux@gmail.com>
To: Makar Semyonov <m.semenov@tssltd.ru>, Saeed Mahameed <saeedm@nvidia.com>
Cc: Leon Romanovsky <leon@kernel.org>,
	Tariq Toukan <tariqt@nvidia.com>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Sabrina Dubroca <sd@queasysnail.net>,
	netdev@vger.kernel.org, linux-rdma@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] eth: mlx5: fix double free of flow_table groups on allocation failure
Date: Mon, 8 Sep 2025 10:28:07 +0300	[thread overview]
Message-ID: <7f9695f0-8753-472a-9e92-585389a6d21e@gmail.com> (raw)
In-Reply-To: <20250904140858.1690639-1-m.semenov@tssltd.ru>



On 04/09/2025 17:08, Makar Semyonov wrote:
> In macsec_fs_rx_create_crypto_table_groups(), when memory allocation for
> 'in' fails, 'ft->g' is cleared once. However, the function returns
> a non-zero error which causes macsec_fs_rx_destroy to be called.
> Inside it, macsec_fs_destroy_flow_table is invoked, which attempts
> to clear 'ft->g' again, leading to a double free.
> 
> This commit fixes the issue by setting 'ft->g' to NULL immediately
> after the first clearance in macsec_fs_rx_create_crypto_table_groups()
> to prevent a double free when macsec_fs_destroy_flow_table attempts to
> free it again.
> 
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
> 
> Signed-off-by: Makar Semyonov <m.semenov@tssltd.ru>
> ---
>   drivers/net/ethernet/mellanox/mlx5/core/lib/macsec_fs.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/macsec_fs.c b/drivers/net/ethernet/mellanox/mlx5/core/lib/macsec_fs.c
> index 4a078113e292..5e86c277f33a 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/lib/macsec_fs.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/macsec_fs.c
> @@ -1066,6 +1066,7 @@ static int macsec_fs_rx_create_crypto_table_groups(struct mlx5_macsec_flow_table
>   	in = kvzalloc(inlen, GFP_KERNEL);
>   	if (!in) {
>   		kfree(ft->g);
> +		ft->g = NULL;
>   		return -ENOMEM;
>   	}
>   

Code and commit message are fine.
Use "net/mlx5" prefix.
Please address comments from Markus Elfring.

      parent reply	other threads:[~2025-09-08  7:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-04 14:08 [PATCH 1/2] eth: mlx5: fix double free of flow_table groups on allocation failure Makar Semyonov
2025-09-04 18:25 ` Markus Elfring
2025-09-08  7:28 ` Tariq Toukan [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7f9695f0-8753-472a-9e92-585389a6d21e@gmail.com \
    --to=ttoukan.linux@gmail.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=m.semenov@tssltd.ru \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=saeedm@nvidia.com \
    --cc=sd@queasysnail.net \
    --cc=tariqt@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox