diff options
author | marius <marius@FreeBSD.org> | 2011-10-09 21:21:37 +0000 |
---|---|---|
committer | marius <marius@FreeBSD.org> | 2011-10-09 21:21:37 +0000 |
commit | 22104b102170d28dd6c7d76778d69a2a78f87522 (patch) | |
tree | 830ef762d05915511d5a0f4353f714038f2a6ea2 /sys/kern/subr_bus.c | |
parent | 8fc9bd139c405d861d838bc2489750ddbf566de7 (diff) | |
download | FreeBSD-src-22104b102170d28dd6c7d76778d69a2a78f87522.zip FreeBSD-src-22104b102170d28dd6c7d76778d69a2a78f87522.tar.gz |
In device_get_children() avoid malloc(0) in order to increase portability
to other operating systems.
PR: 154287
Diffstat (limited to 'sys/kern/subr_bus.c')
-rw-r--r-- | sys/kern/subr_bus.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c index e688ca0..4a36a8b 100644 --- a/sys/kern/subr_bus.c +++ b/sys/kern/subr_bus.c @@ -2140,6 +2140,11 @@ device_get_children(device_t dev, device_t **devlistp, int *devcountp) TAILQ_FOREACH(child, &dev->children, link) { count++; } + if (count == 0) { + *devlistp = NULL; + *devcountp = 0; + return (0); + } list = malloc(count * sizeof(device_t), M_TEMP, M_NOWAIT|M_ZERO); if (!list) |