Skip to content

Commit

Permalink
Fix -fsanitize=address memory leak
Browse files Browse the repository at this point in the history
kmem_alloc(0, ...) in userspace returns a leakable pointer.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: DHE <git@dehacked.net>
Issue #6941
  • Loading branch information
DeHackEd authored and behlendorf committed Jan 9, 2018
1 parent be54a13 commit 460f239
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions module/zfs/spa.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 460f239

Please sign in to comment.