diff options
author | Andy Fiddaman <omnios@citrus-it.co.uk> | 2021-07-08 13:16:10 +0000 |
---|---|---|
committer | Andy Fiddaman <omnios@citrus-it.co.uk> | 2021-07-27 15:15:07 +0000 |
commit | f3a2bc1eccb884e62be4c0b42935466b79b1342d (patch) | |
tree | 1a87d1e8f8cc3466d952051983539f03af84b102 /usr/src | |
parent | b4ceea05088ba1b5fae1914544a808623516aa80 (diff) | |
download | illumos-joyent-f3a2bc1eccb884e62be4c0b42935466b79b1342d.tar.gz |
6161 zero-sized kmem_alloc() in zfs`spa_load_l2cache
Reviewed by: Andrew Stormont <andyjstormont@gmail.com>
Reviewed by: Jason King <jason.brian.king@gmail.com>
Approved by: Dan McDonald <danmcd@joyent.com>
Diffstat (limited to 'usr/src')
-rw-r--r-- | usr/src/uts/common/fs/zfs/spa.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/usr/src/uts/common/fs/zfs/spa.c b/usr/src/uts/common/fs/zfs/spa.c index bf3e8a6fd4..70d690d587 100644 --- a/usr/src/uts/common/fs/zfs/spa.c +++ b/usr/src/uts/common/fs/zfs/spa.c @@ -30,8 +30,8 @@ * Copyright (c) 2017, 2019, Datto Inc. All rights reserved. * Copyright 2019 Joyent, Inc. * Copyright (c) 2017, Intel Corporation. - * Copyright 2018 OmniOS Community Edition (OmniOSce) Association. * Copyright 2020 Joshua M. Clulow <josh@sysmgr.org> + * Copyright 2021 OmniOS Community Edition (OmniOSce) Association. */ /* @@ -1731,13 +1731,15 @@ spa_load_l2cache(spa_t *spa) ASSERT(spa_config_held(spa, SCL_ALL, RW_WRITER) == SCL_ALL); + nl2cache = 0; + newvdevs = NULL; if (sav->sav_config != NULL) { VERIFY(nvlist_lookup_nvlist_array(sav->sav_config, ZPOOL_CONFIG_L2CACHE, &l2cache, &nl2cache) == 0); - newvdevs = kmem_alloc(nl2cache * sizeof (void *), KM_SLEEP); - } else { - nl2cache = 0; - newvdevs = NULL; + if (nl2cache > 0) { + newvdevs = kmem_alloc( + nl2cache * sizeof (void *), KM_SLEEP); + } } oldvdevs = sav->sav_vdevs; @@ -1829,7 +1831,11 @@ 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); + l2cache = NULL; + 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); |