git: 034af6afc542 - stable/13 - cxgbe: Handle requests for TLS key allocations with no TLS key storage.

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Fri, 11 Nov 2022 00:39:05 UTC
The branch stable/13 has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=034af6afc542948b534176a037a990a255ea73f0

commit 034af6afc542948b534176a037a990a255ea73f0
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2022-08-08 18:21:54 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2022-11-11 00:35:47 +0000

    cxgbe: Handle requests for TLS key allocations with no TLS key storage.
    
    If an adapter advertises support for TLS keys but an empty TLS key
    storage area in on-board memory, fail the request rather than invoking
    vmem_alloc on an uninitialized vmem.
    
    Sponsored by:   Chelsio Communications
    
    (cherry picked from commit 1ca4f45ea89f10621bf7e9cfea1705d0a7940bea)
---
 sys/dev/cxgbe/crypto/t4_keyctx.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/sys/dev/cxgbe/crypto/t4_keyctx.c b/sys/dev/cxgbe/crypto/t4_keyctx.c
index b64eb4ff23d7..11f5598c31a5 100644
--- a/sys/dev/cxgbe/crypto/t4_keyctx.c
+++ b/sys/dev/cxgbe/crypto/t4_keyctx.c
@@ -640,6 +640,9 @@ t4_alloc_tls_keyid(struct adapter *sc)
 {
 	vmem_addr_t addr;
 
+	if (sc->vres.key.size == 0)
+		return (-1);
+
 	if (vmem_alloc(sc->key_map, TLS_KEY_CONTEXT_SZ, M_NOWAIT | M_FIRSTFIT,
 	    &addr) != 0)
 		return (-1);