netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Haoxiang Li <haoxiang_li2024@163.com>
Cc: jgg@ziepe.ca, sd@queasysnail.net, phaddad@nvidia.com,
	linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org,
	netdev@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH] mlx5: Add check for get_macsec_device()
Date: Wed, 19 Feb 2025 14:30:57 +0200	[thread overview]
Message-ID: <20250219123057.GF53094@unreal> (raw)
In-Reply-To: <20250218100200.2535141-1-haoxiang_li2024@163.com>

On Tue, Feb 18, 2025 at 06:02:00PM +0800, Haoxiang Li wrote:
> Add check for the return value of get_macsec_device() in
> mlx5r_del_gid_macsec_operations() to prevent null pointer
> dereference.
> 
> Fixes: 58dbd6428a68 ("RDMA/mlx5: Handles RoCE MACsec steering rules addition and deletion")
> Cc: stable@vger.kernel.org

Definitely not.

> Signed-off-by: Haoxiang Li <haoxiang_li2024@163.com>
> ---
>  drivers/infiniband/hw/mlx5/macsec.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/infiniband/hw/mlx5/macsec.c b/drivers/infiniband/hw/mlx5/macsec.c
> index 3c56eb5eddf3..623b0a58f721 100644
> --- a/drivers/infiniband/hw/mlx5/macsec.c
> +++ b/drivers/infiniband/hw/mlx5/macsec.c
> @@ -354,6 +354,11 @@ void mlx5r_del_gid_macsec_operations(const struct ib_gid_attr *attr)
>  		}
>  	}
>  	macsec_device = get_macsec_device(ndev, &dev->macsec.macsec_devices_list);

At this stage macsec_device is valid.

> +	if (!macsec_device) {
> +		dev_put(ndev);
> +		mutex_unlock(&dev->macsec.lock);
> +		return;
> +	}
>  	mlx5_macsec_del_roce_rule(attr->index, dev->mdev->macsec_fs,
>  				  &macsec_device->tx_rules_list, &macsec_device->rx_rules_list);
>  	mlx5_macsec_del_roce_gid(macsec_device, attr->index);
> -- 
> 2.25.1
> 

      reply	other threads:[~2025-02-19 12:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-18 10:02 [PATCH] mlx5: Add check for get_macsec_device() Haoxiang Li
2025-02-19 12:30 ` Leon Romanovsky [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=20250219123057.GF53094@unreal \
    --to=leon@kernel.org \
    --cc=haoxiang_li2024@163.com \
    --cc=jgg@ziepe.ca \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=phaddad@nvidia.com \
    --cc=sd@queasysnail.net \
    --cc=stable@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).