aboutsummaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
authorDHE <[email protected]>2017-11-18 18:21:09 -0500
committerBrian Behlendorf <[email protected]>2018-01-09 12:26:25 -0800
commit460f239e6999195dbcf9b8443c029f07765b21e9 (patch)
tree1fe4b79d770f19618a0933334bef6e6d82d570f4 /module
parentbe54a13c3e7db423ffdb3f7983d4dd1141cc94a0 (diff)
Fix -fsanitize=address memory leak
kmem_alloc(0, ...) in userspace returns a leakable pointer. Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: DHE <[email protected]> Issue #6941
Diffstat (limited to 'module')
-rw-r--r--module/zfs/spa.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/module/zfs/spa.c b/module/zfs/spa.c
index 8844b9f7b..75b928620 100644
--- a/module/zfs/spa.c
+++ b/module/zfs/spa.c
@@ -1563,7 +1563,7 @@ spa_load_spares(spa_t *spa)
static void
spa_load_l2cache(spa_t *spa)
{
- nvlist_t **l2cache;
+ nvlist_t **l2cache = NULL;
uint_t nl2cache;
int i, j, oldnvdevs;
uint64_t guid;
@@ -1647,7 +1647,9 @@ spa_load_l2cache(spa_t *spa)
VERIFY(nvlist_remove(sav->sav_config, ZPOOL_CONFIG_L2CACHE,
DATA_TYPE_NVLIST_ARRAY) == 0);
- l2cache = kmem_alloc(sav->sav_count * sizeof (void *), KM_SLEEP);
+ if (sav->sav_count > 0)
+ l2cache = kmem_alloc(sav->sav_count * sizeof (void *),
+ KM_SLEEP);
for (i = 0; i < sav->sav_count; i++)
l2cache[i] = vdev_config_generate(spa,
sav->sav_vdevs[i], B_TRUE, VDEV_CONFIG_L2CACHE);