diff options
author | Jerry Jelinek <jerry.jelinek@joyent.com> | 2020-08-06 11:34:40 +0000 |
---|---|---|
committer | Jerry Jelinek <jerry.jelinek@joyent.com> | 2020-08-06 11:34:40 +0000 |
commit | 917cee0d014d2e42d3dcada785a76c0ad868515a (patch) | |
tree | e4f41f830eee4ac8b921882edc596dd7bdfa9614 /usr/src/lib/libdiskmgt/common/findevs.c | |
parent | 4ff31f76cff40104f343d4135967abf1b00edd66 (diff) | |
parent | be235d17490f6a5ad01c6a5319530fce66d88389 (diff) | |
download | illumos-joyent-917cee0d014d2e42d3dcada785a76c0ad868515a.tar.gz |
[illumos-gate merge]
commit be235d17490f6a5ad01c6a5319530fce66d88389
12801 libdiskmgt leaks PROM device information handles like a sieve
commit bd05d33960c9701232eaa8bdb6a5ce585912ffc6
13016 bhyve cannot emulate MMIO from bootrom
commit 2c834067bf731e663c6269489bf5dc0a9b4c6299
12977 smb3 server encryption leak in smb2_send_reply
commit fe417ad0efdf365d5438ae46904118fa27ae38b8
12853 bhyve manifests should include BSD license
commit 1a10a9077a9effc574b7f797a4d321dd0cea4197
12419 intel_nb5000: variable may be used uninitialized
Diffstat (limited to 'usr/src/lib/libdiskmgt/common/findevs.c')
-rw-r--r-- | usr/src/lib/libdiskmgt/common/findevs.c | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/usr/src/lib/libdiskmgt/common/findevs.c b/usr/src/lib/libdiskmgt/common/findevs.c index 2ac0e6cada..53a0b121fb 100644 --- a/usr/src/lib/libdiskmgt/common/findevs.c +++ b/usr/src/lib/libdiskmgt/common/findevs.c @@ -28,6 +28,7 @@ * Copyright (c) 2011 by Delphix. All rights reserved. * Copyright 2017 Nexenta Systems, Inc. * Copyright 2017 Joyent, Inc. + * Copyright 2020 Oxide Computer Company */ #include <fcntl.h> @@ -151,8 +152,23 @@ findevs(struct search_args *args) args->controller_listp = NULL; args->disk_listp = NULL; + args->ph = DI_PROM_HANDLE_NIL; + args->handle = DI_LINK_NIL; args->dev_walk_status = 0; - args->handle = di_devlink_init(NULL, 0); + + /* + * Create device information library handles, which must be destroyed + * before we return. + */ + if ((args->ph = di_prom_init()) == DI_PROM_HANDLE_NIL || + (args->handle = di_devlink_init(NULL, 0)) == DI_LINK_NIL) { + /* + * We could not open all of the handles we need, so clean up + * and report failure to the caller. + */ + args->dev_walk_status = errno; + goto cleanup; + } /* * Have to make several passes at this with the new devfs caching. @@ -160,7 +176,6 @@ findevs(struct search_args *args) * devices. */ di_root = di_init("/", DINFOCACHE); - args->ph = di_prom_init(); (void) di_walk_minor(di_root, NULL, 0, args, add_devs); di_fini(di_root); @@ -168,9 +183,16 @@ findevs(struct search_args *args) (void) di_walk_minor(di_root, NULL, 0, args, add_devs); di_fini(di_root); - (void) di_devlink_fini(&(args->handle)); - clean_paths(args); + +cleanup: + if (args->ph != DI_PROM_HANDLE_NIL) { + di_prom_fini(args->ph); + args->ph = DI_PROM_HANDLE_NIL; + } + if (args->handle != DI_LINK_NIL) { + (void) di_devlink_fini(&(args->handle)); + } } /* |