diff options
author | LOLi <[email protected]> | 2018-11-12 03:09:00 +0100 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2018-11-11 18:09:00 -0800 |
commit | c8fd652ce7abe85c5238356248d1918ea9ff5ff8 (patch) | |
tree | 5caf9008e532c92a5566557df9c5622d6152446d | |
parent | ecd3728b264b94de239932555b7046f1ddb936b2 (diff) |
Fix coverity defects: CID 184285
CID 184285: Read from pointer after free (USE_AFTER_FREE)
This patch fixes an use-after-free in vdev_config_generate_stats()
moving the kmem_free() call at the end of the function.
Reviewed-by: George Melikov <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: Giuseppe Di Natale <[email protected]>
Signed-off-by: loli10K <[email protected]>
Closes #8120
-rw-r--r-- | module/zfs/vdev_label.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/module/zfs/vdev_label.c b/module/zfs/vdev_label.c index f99085146..65b847d66 100644 --- a/module/zfs/vdev_label.c +++ b/module/zfs/vdev_label.c @@ -228,8 +228,6 @@ vdev_config_generate_stats(vdev_t *vd, nvlist_t *nv) fnvlist_add_uint64_array(nv, ZPOOL_CONFIG_VDEV_STATS, (uint64_t *)vs, sizeof (*vs) / sizeof (uint64_t)); - kmem_free(vs, sizeof (*vs)); - /* * Add extended stats into a special extended stats nvlist. This keeps * all the extended stats nicely grouped together. The extended stats @@ -354,6 +352,7 @@ vdev_config_generate_stats(vdev_t *vd, nvlist_t *nv) fnvlist_add_nvlist(nv, ZPOOL_CONFIG_VDEV_STATS_EX, nvx); fnvlist_free(nvx); + kmem_free(vs, sizeof (*vs)); kmem_free(vsx, sizeof (*vsx)); } |