git: 462b6c50c708 - main - ena: Fix NULL deref before NULL check in RSS sysctl

From: Arthur Kiyanovski <akiyano_at_FreeBSD.org>
Date: Thu, 29 Oct 2026 03:29:39 UTC
The branch main has been updated by akiyano:

URL: https://cgit.FreeBSD.org/src/commit/?id=462b6c50c7089e96c54cbd34378467f32fc709d4

commit 462b6c50c7089e96c54cbd34378467f32fc709d4
Author:     Evgeny Ostrovsky <evostrov@amazon.com>
AuthorDate: 2026-05-26 07:01:39 +0000
Commit:     Arthur Kiyanovski <akiyano@FreeBSD.org>
CommitDate: 2026-10-29 03:25:50 +0000

    ena: Fix NULL deref before NULL check in RSS sysctl
    
    In ena_sysctl_rss_indir_table(), the code dereferenced
    indir->sysctl_buf before checking whether indir itself is NULL.
    Move the NULL check above the dereference so the early-return path
    fires before any access through indir.
    
    Reviewed by: cperciva
    Fixes: 6d1ef2abd330 ("ena: Implement full RSS reconfiguration")
    MFC after: 3 days
    Sponsored by: Amazon, Inc.
---
 sys/dev/ena/ena_sysctl.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/sys/dev/ena/ena_sysctl.c b/sys/dev/ena/ena_sysctl.c
index 62fded932025..74ab16d1b977 100644
--- a/sys/dev/ena/ena_sysctl.c
+++ b/sys/dev/ena/ena_sysctl.c
@@ -1160,12 +1160,11 @@ ena_sysctl_rss_indir_table(SYSCTL_HANDLER_ARGS)
 	}
 
 	indir = adapter->rss_indir;
-	msg = indir->sysctl_buf;
-
 	if (unlikely(indir == NULL)) {
 		error = ENOTSUP;
 		goto unlock;
 	}
+	msg = indir->sysctl_buf;
 
 	error = sysctl_handle_string(oidp, msg, indir->record_size
 	    * indir->table_size, req);