The branch main has been updated by mjg:

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

commit 234683726708cf5212d672d676d30056d4133859
Author:     Mateusz Guzik <m...@freebsd.org>
AuthorDate: 2025-03-06 11:01:49 +0000
Commit:     Mateusz Guzik <m...@freebsd.org>
CommitDate: 2025-03-06 11:01:49 +0000

    devclass: make devclass_alloc_unit use M_NOWAIT
    
    The only caller already does this.
    
    The routine can be called with a mutex held making M_WAITOK illegal.
    
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
---
 sys/kern/subr_bus.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c
index 9506e471705c..0422352bba51 100644
--- a/sys/kern/subr_bus.c
+++ b/sys/kern/subr_bus.c
@@ -1208,6 +1208,7 @@ 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;
 
@@ -1264,8 +1265,11 @@ devclass_alloc_unit(devclass_t dc, device_t dev, int 
*unitp)
                int newsize;
 
                newsize = unit + 1;
-               dc->devices = reallocf(dc->devices,
-                   newsize * sizeof(*dc->devices), M_BUS, M_WAITOK);
+               devices = reallocf(dc->devices,
+                   newsize * sizeof(*dc->devices), M_BUS, M_NOWAIT);
+               if (devices == NULL)
+                       return (ENOMEM);
+               dc->devices = devices;
                memset(dc->devices + dc->maxunit, 0,
                    sizeof(device_t) * (newsize - dc->maxunit));
                dc->maxunit = newsize;

Reply via email to