diff options
author | phk <phk@FreeBSD.org> | 2002-09-30 07:56:12 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 2002-09-30 07:56:12 +0000 |
commit | 19353735723780cda7641c685e35d14dbb357cdb (patch) | |
tree | 087c52651f00285022d841ac1a2cd8cee061fa9d | |
parent | 71b10d2a60c58d23bfcb6b4e67ca672807cba6f8 (diff) | |
download | FreeBSD-src-19353735723780cda7641c685e35d14dbb357cdb.zip FreeBSD-src-19353735723780cda7641c685e35d14dbb357cdb.tar.gz |
Don't leak memory in case device_add_child_ordered() returns NULL.
Found by: FlexeLint
-rw-r--r-- | sys/isa/isa_common.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/sys/isa/isa_common.c b/sys/isa/isa_common.c index 2d5a866..8b8034b 100644 --- a/sys/isa/isa_common.c +++ b/sys/isa/isa_common.c @@ -627,6 +627,10 @@ isa_add_child(device_t dev, int order, const char *name, int unit) device_t child; struct isa_device *idev; + child = device_add_child_ordered(dev, order, name, unit); + if (child == NULL) + return (child); + idev = malloc(sizeof(struct isa_device), M_ISADEV, M_NOWAIT | M_ZERO); if (!idev) return 0; @@ -634,10 +638,9 @@ isa_add_child(device_t dev, int order, const char *name, int unit) resource_list_init(&idev->id_resources); TAILQ_INIT(&idev->id_configs); - child = device_add_child_ordered(dev, order, name, unit); - device_set_ivars(child, idev); + device_set_ivars(child, idev); - return child; + return (child); } static int |