Date: Thu, 2 Jul 2020 07:03:15 +0000 (UTC) From: Toomas Soome <tsoome@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r362883 - head/stand/libsa/zfs Message-ID: <202007020703.06273FoX071286@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: tsoome Date: Thu Jul 2 07:03:15 2020 New Revision: 362883 URL: https://svnweb.freebsd.org/changeset/base/362883 Log: loader: potential memory leak and check return values Need to free nvlist before return from vdev_from_nvlist(). Sponsored by: Netflix, Klara Inc. Modified: head/stand/libsa/zfs/zfsimpl.c Modified: head/stand/libsa/zfs/zfsimpl.c ============================================================================== --- head/stand/libsa/zfs/zfsimpl.c Thu Jul 2 01:10:18 2020 (r362882) +++ head/stand/libsa/zfs/zfsimpl.c Thu Jul 2 07:03:15 2020 (r362883) @@ -1111,14 +1111,20 @@ vdev_from_nvlist(spa_t *spa, uint64_t top_guid, const 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 nvlis 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 *nvli 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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202007020703.06273FoX071286>