The branch stable/12 has been updated by kevans:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=1767656525c5ab8cdcc9309846023bf2d94e735d

commit 1767656525c5ab8cdcc9309846023bf2d94e735d
Author:     Toomas Soome <[email protected]>
AuthorDate: 2020-07-02 07:03:15 +0000
Commit:     Kyle Evans <[email protected]>
CommitDate: 2021-10-08 05:24:26 +0000

    loader: potential memory leak and check return values
    
    Need to free nvlist before return from vdev_from_nvlist().
    
    (cherry picked from commit 045f497cbc6cb67bc563d7f2378bf9535044bb2d)
---
 stand/libsa/zfs/zfsimpl.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/stand/libsa/zfs/zfsimpl.c b/stand/libsa/zfs/zfsimpl.c
index fe04d3b1db21..cc35f3d06f0e 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 {
                rc = 0;
@@ -1224,6 +1230,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;
@@ -1286,7 +1294,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);
 

Reply via email to