git: dfd9c9bc3f86 - stable/13 - umtx: handle allocation failire in umtx_pi_alloc()

From: Kristof Provost <kp_at_FreeBSD.org>
Date: Sun, 12 Jan 2025 10:20:30 UTC
The branch stable/13 has been updated by kp:

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

commit dfd9c9bc3f8627a15443f9bfc068a7eade2d688c
Author:     Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2025-01-05 16:09:08 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2025-01-12 09:46:31 +0000

    umtx: handle allocation failire in umtx_pi_alloc()
    
    Don't assume that this allocation will succeed. We may have been passed
    M_NOWAIT.
    
    The calling code already handles allocation failures, but the function
    itself did not.
    
    PR:             283807
    MFC after:      1 week
    
    (cherry picked from commit 50c1e179b584f43ba82e9afc91b25ec4831b58ef)
---
 sys/kern/kern_umtx.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/sys/kern/kern_umtx.c b/sys/kern/kern_umtx.c
index 61b86d0b62b1..5929a355f4a6 100644
--- a/sys/kern/kern_umtx.c
+++ b/sys/kern/kern_umtx.c
@@ -1740,6 +1740,9 @@ umtx_pi_alloc(int flags)
 	struct umtx_pi *pi;
 
 	pi = uma_zalloc(umtx_pi_zone, M_ZERO | flags);
+	if (pi == NULL)
+		return (NULL);
+
 	TAILQ_INIT(&pi->pi_blocked);
 	atomic_add_int(&umtx_pi_allocated, 1);
 	return (pi);