Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 29 Jan 2012 00:41:08 +0000 (UTC)
From:      Marius Strobl <marius@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r230696 - stable/8/sys/kern
Message-ID:  <201201290041.q0T0f8iF007504@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: marius
Date: Sun Jan 29 00:41:08 2012
New Revision: 230696
URL: http://svn.freebsd.org/changeset/base/230696

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

Modified:
  stable/8/sys/kern/subr_bus.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)

Modified: stable/8/sys/kern/subr_bus.c
==============================================================================
--- stable/8/sys/kern/subr_bus.c	Sun Jan 29 00:40:39 2012	(r230695)
+++ stable/8/sys/kern/subr_bus.c	Sun Jan 29 00:41:08 2012	(r230696)
@@ -2176,6 +2176,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?201201290041.q0T0f8iF007504>