diff options
author | Toomas Soome <tsoome@FreeBSD.org> | 2020-07-02 07:03:15 +0000 |
---|---|---|
committer | Toomas Soome <tsoome@FreeBSD.org> | 2020-07-02 07:03:15 +0000 |
commit | 045f497cbc6cb67bc563d7f2378bf9535044bb2d (patch) | |
tree | 8b16c0b55f7e8ee5a1a1a0d463395a0e1c24829e /stand | |
parent | b865714d953167a48defc516c86fa762be0c1bd9 (diff) | |
download | src-test-045f497cbc6cb67bc563d7f2378bf9535044bb2d.tar.gz src-test-045f497cbc6cb67bc563d7f2378bf9535044bb2d.zip |
loader: potential memory leak and check return values
Need to free nvlist before return from vdev_from_nvlist().
Sponsored by: Netflix, Klara Inc.
Notes
Notes:
svn path=/head/; revision=362883
Diffstat (limited to 'stand')
-rw-r--r-- | stand/libsa/zfs/zfsimpl.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/stand/libsa/zfs/zfsimpl.c b/stand/libsa/zfs/zfsimpl.c index 1e11ba9daf610..a6b8bf968b5e6 100644 --- a/stand/libsa/zfs/zfsimpl.c +++ b/stand/libsa/zfs/zfsimpl.c @@ -1111,14 +1111,20 @@ vdev_from_nvlist(spa_t *spa, uint64_t top_guid, const nvlist_t *nvlist) return (rc); } rc = vdev_init(guid, kids, &vdev); - if (rc != 0) + if (rc != 0) { + nvlist_destroy(kids); return (rc); + } vdev->v_spa = spa; vdev->v_top = top_vdev; vdev_insert(top_vdev, vdev); rc = nvlist_next(kids); + if (rc != 0) { + nvlist_destroy(kids); + return (rc); + } } } else { /* @@ -1228,6 +1234,8 @@ vdev_update_from_nvlist(uint64_t top_guid, const nvlist_t *nvlist) vdev_set_initial_state(vdev, kids); rc = nvlist_next(kids); + if (rc != 0) + break; } } else { rc = 0; @@ -1290,7 +1298,9 @@ vdev_init_from_nvlist(spa_t *spa, const nvlist_t *nvlist) rc = vdev_update_from_nvlist(guid, kids); if (rc != 0) break; - nvlist_next(kids); + rc = nvlist_next(kids); + if (rc != 0) + break; } nvlist_destroy(kids); |