From: lirongqing <lirongqing@baidu.com>
To: Leon Romanovsky <leon@kernel.org>, Jason Gunthorpe <jgg@ziepe.ca>,
<linux-rdma@vger.kernel.org>
Cc: Li RongQing <lirongqing@baidu.com>
Subject: [PATCH] RDMA/mlx5: Fix NULL deref in del_sa_roce_rule() on allocation failure
Date: Fri, 2 Oct 2026 19:03:29 +0800 [thread overview]
Message-ID: <20261002110329.2350-1-lirongqing@baidu.com> (raw)
From: Li RongQing <lirongqing@baidu.com>
get_macsec_device() allocates and links a new mlx5_macsec_device when
the macdev has no existing entry, and returns NULL when that allocation
fails. del_sa_roce_rule() only flagged the NULL case with WARN_ON() and
kept dereferencing macsec_device, so a MACsec SA delete event for a
macdev that was never set up by the RoCE GID path would dereference NULL
under memory pressure.
Return after the warning so the SA delete event is dropped instead of
oopsing.
Fixes: 58dbd6428a68 ("RDMA/mlx5: Handles RoCE MACsec steering rules addition and deletion")
Signed-off-by: Li RongQing <lirongqing@baidu.com>
---
drivers/infiniband/hw/mlx5/macsec.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/infiniband/hw/mlx5/macsec.c b/drivers/infiniband/hw/mlx5/macsec.c
index 4732be5..37394ea 100644
--- a/drivers/infiniband/hw/mlx5/macsec.c
+++ b/drivers/infiniband/hw/mlx5/macsec.c
@@ -119,7 +119,8 @@ static void del_sa_roce_rule(struct list_head *macsec_devices_list,
struct mlx5_macsec_device *macsec_device;
macsec_device = get_macsec_device(data->macdev, macsec_devices_list);
- WARN_ON(!macsec_device);
+ if (WARN_ON(!macsec_device))
+ return;
mlx5_macsec_del_roce_sa_rules(data->fs_id, data->macsec_fs,
&macsec_device->tx_rules_list,
--
2.9.4
next reply other threads:[~2026-10-02 11:03 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-02 11:03 lirongqing [this message]
2026-10-02 11:14 ` [PATCH] RDMA/mlx5: Fix NULL deref in del_sa_roce_rule() on allocation failure sashiko-bot
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=20261002110329.2350-1-lirongqing@baidu.com \
--to=lirongqing@baidu.com \
--cc=jgg@ziepe.ca \
--cc=leon@kernel.org \
--cc=linux-rdma@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