git: 284e06dec78f - main - mlx5: guard against a NULL CQ event handler in mlx5_cq_event()

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Tue, 07 Jul 2026 11:30:10 UTC
The branch main has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=284e06dec78ffbbf8919dc0aa11073ecabba7176

commit 284e06dec78ffbbf8919dc0aa11073ecabba7176
Author:     Ariel Ehrenberg <aehrenberg@nvidia.com>
AuthorDate: 2026-06-15 08:16:17 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2026-07-07 11:25:41 +0000

    mlx5: guard against a NULL CQ event handler in mlx5_cq_event()
    
    DEVX and mlx5en created CQs are registered without an asynchronous
    event handler (mcq.event is NULL).  An asynchronous CQ_ERROR event for
    such a CQ made mlx5_cq_event() call through a NULL pointer and panic.
    
    Reviewed by:    kib
    Tested by:      Wafa Hamzah <wafah@nvidia.com>
    Sponsored by:   Nvidia networking
    MFC after:      1 month
---
 sys/dev/mlx5/mlx5_core/mlx5_cq.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sys/dev/mlx5/mlx5_core/mlx5_cq.c b/sys/dev/mlx5/mlx5_core/mlx5_cq.c
index fa28ae6dece9..f1f8fc03de6c 100644
--- a/sys/dev/mlx5/mlx5_core/mlx5_cq.c
+++ b/sys/dev/mlx5/mlx5_core/mlx5_cq.c
@@ -113,7 +113,8 @@ void mlx5_cq_event(struct mlx5_core_dev *dev, u32 cqn, int event_type)
 		spin_unlock(&table->writerlock);
 
 	if (likely(cq != NULL)) {
-		cq->event(cq, event_type);
+		if (cq->event)
+			cq->event(cq, event_type);
 	} else {
 		mlx5_core_warn(dev,
 		    "Asynchronous event for bogus CQ 0x%x\n", cqn);