From da02572e7fbd8cc8e1055e935c48d6e9957db107 Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Sat, 23 Aug 2008 07:38:00 +0000 Subject: [PATCH] Handle errors from device_get_chidlren. Free child list when there's more children than we expected. --- sys/dev/iicbus/iiconf.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sys/dev/iicbus/iiconf.c b/sys/dev/iicbus/iiconf.c index bf7f4533e22..1610b351e74 100644 --- a/sys/dev/iicbus/iiconf.c +++ b/sys/dev/iicbus/iiconf.c @@ -366,9 +366,12 @@ iicbus_transfer_gen(device_t dev, struct iic_msg *msgs, uint32_t nmsgs) int i, error, lenread, lenwrote, nkid; device_t *children, bus; - device_get_children(dev, &children, &nkid); - if (nkid != 1) + if ((error = device_get_children(dev, &children, &nkid)) != 0) + return (error); + if (nkid != 1) { + free(children, M_TEMP); return (EIO); + } bus = children[0]; free(children, M_TEMP); for (i = 0, error = 0; i < nmsgs && error == 0; i++) {