From 6a7967253064a0b8711ca746a1296ee6439d36e6 Mon Sep 17 00:00:00 2001 From: Chunwei Chen Date: Fri, 27 May 2016 15:48:02 -0700 Subject: [PATCH] Fix memleak in vdev_config_generate_stats fnvlist_add_nvlist will copy the contents of nvx, so we need to free it here. unreferenced object 0xffff8800a6934e80 (size 64): comm "zpool", pid 3398, jiffies 4295007406 (age 214.180s) hex dump (first 32 bytes): 60 06 c2 73 00 88 ff ff 00 7c 8c 73 00 88 ff ff `..s.....|.s.... 00 00 00 00 00 00 00 00 40 b0 70 c0 ff ff ff ff ........@.p..... backtrace: [] kmemleak_alloc+0x4e/0xb0 [] __kmalloc_node+0x17d/0x310 [] spl_kmem_alloc_impl+0xac/0x180 [spl] [] spl_vmem_alloc+0x19/0x20 [spl] [] nv_alloc_sleep_spl+0x1f/0x30 [znvpair] [] nvlist_xalloc.part.13+0x27/0xc0 [znvpair] [] nvlist_alloc+0x3d/0x40 [znvpair] [] fnvlist_alloc+0x2c/0x80 [znvpair] [] vdev_config_generate_stats+0x83/0x370 [zfs] [] vdev_config_generate+0x4e3/0x650 [zfs] [] spa_config_generate+0x20b/0x4b0 [zfs] [] spa_tryimport+0xc4/0x430 [zfs] [] zfs_ioc_pool_tryimport+0x68/0x110 [zfs] [] zfsdev_ioctl+0x646/0x7a0 [zfs] [] do_vfs_ioctl+0xa1/0x5b0 [] SyS_ioctl+0x79/0x90 Signed-off-by: Chunwei Chen Signed-off-by: Tony Hutter Signed-off-by: Brian Behlendorf Closes #4707 Issue #4708 --- module/zfs/vdev_label.c | 1 + 1 file changed, 1 insertion(+) diff --git a/module/zfs/vdev_label.c b/module/zfs/vdev_label.c index 59bce1370..1925c67ed 100644 --- a/module/zfs/vdev_label.c +++ b/module/zfs/vdev_label.c @@ -346,6 +346,7 @@ vdev_config_generate_stats(vdev_t *vd, nvlist_t *nv) /* Add extended stats nvlist to main nvlist */ fnvlist_add_nvlist(nv, ZPOOL_CONFIG_VDEV_STATS_EX, nvx); + fnvlist_free(nvx); kmem_free(vsx, sizeof (*vsx)); }