git: 78cd83e4017b - main - devclass_alloc_unit: Go back to using M_WAITOK

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Mon, 10 Mar 2025 17:35:44 UTC
The branch main has been updated by jhb:

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

commit 78cd83e4017bccf62a291e57f0cceccf80e50423
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2025-03-10 17:34:44 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2025-03-10 17:34:44 +0000

    devclass_alloc_unit: Go back to using M_WAITOK
    
    This restores a change made earlier in f3d3c63442fff.
    
    This reverts commit 234683726708cf5212d672d676d30056d4133859.
    
    Reviewed by:    imp
    Differential Revision:  https://reviews.freebsd.org/D49273
---
 sys/kern/subr_bus.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c
index 38a8cab639e4..63de61262554 100644
--- a/sys/kern/subr_bus.c
+++ b/sys/kern/subr_bus.c
@@ -1211,7 +1211,6 @@ devclass_get_sysctl_tree(devclass_t dc)
 static int
 devclass_alloc_unit(devclass_t dc, device_t dev, int *unitp)
 {
-	device_t *devices;
 	const char *s;
 	int unit = *unitp;
 
@@ -1268,11 +1267,8 @@ devclass_alloc_unit(devclass_t dc, device_t dev, int *unitp)
 		int newsize;
 
 		newsize = unit + 1;
-		devices = reallocf(dc->devices,
-		    newsize * sizeof(*dc->devices), M_BUS, M_NOWAIT);
-		if (devices == NULL)
-			return (ENOMEM);
-		dc->devices = devices;
+		dc->devices = reallocf(dc->devices,
+		    newsize * sizeof(*dc->devices), M_BUS, M_WAITOK);
 		memset(dc->devices + dc->maxunit, 0,
 		    sizeof(device_t) * (newsize - dc->maxunit));
 		dc->maxunit = newsize;