summaryrefslogtreecommitdiffstats
path: root/sys/kern
diff options
context:
space:
mode:
authormarius <marius@FreeBSD.org>2011-10-09 21:21:37 +0000
committermarius <marius@FreeBSD.org>2011-10-09 21:21:37 +0000
commit22104b102170d28dd6c7d76778d69a2a78f87522 (patch)
tree830ef762d05915511d5a0f4353f714038f2a6ea2 /sys/kern
parent8fc9bd139c405d861d838bc2489750ddbf566de7 (diff)
downloadFreeBSD-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')
-rw-r--r--sys/kern/subr_bus.c5
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)
OpenPOWER on IntegriCloud