Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 9 Oct 2011 21:21:37 +0000 (UTC)
From:      Marius Strobl <marius@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r226175 - head/sys/kern
Message-ID:  <201110092121.p99LLbYB027232@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: marius
Date: Sun Oct  9 21:21:37 2011
New Revision: 226175
URL: http://svn.freebsd.org/changeset/base/226175

Log:
  In device_get_children() avoid malloc(0) in order to increase portability
  to other operating systems.
  
  PR:     154287

Modified:
  head/sys/kern/subr_bus.c

Modified: head/sys/kern/subr_bus.c
==============================================================================
--- head/sys/kern/subr_bus.c	Sun Oct  9 20:58:02 2011	(r226174)
+++ head/sys/kern/subr_bus.c	Sun Oct  9 21:21:37 2011	(r226175)
@@ -2140,6 +2140,11 @@ device_get_children(device_t dev, device
 	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)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201110092121.p99LLbYB027232>