Skip to content

Commit

Permalink
Initialize "autoreplace" in spa_ld_get_props()
Browse files Browse the repository at this point in the history
spa_prop_find() may fail to find the specified property, in which case
it suppresses ENOENT from zap_lookup().  In this case, the return value
is left uninitialized, so spa_autoreplace was being initialized using an
uninitialized stack variable.

This was found using KMSAN.  It appears to be a regression from commit
9eb7b46, which removed the initialization of "autoreplace" from the
definition.

Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: Alexander Motin <[email protected]>
Signed-off-by: Mark Johnston <[email protected]>
Closes #12383
  • Loading branch information
markjdb authored and behlendorf committed Jul 26, 2021
1 parent 1c24bf9 commit da27b8b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion module/zfs/spa.c
Original file line number Diff line number Diff line change
Expand Up @@ -4183,7 +4183,7 @@ spa_ld_get_props(spa_t *spa)
return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA, EIO));

if (error == 0) {
uint64_t autoreplace;
uint64_t autoreplace = 0;

spa_prop_find(spa, ZPOOL_PROP_BOOTFS, &spa->spa_bootfs);
spa_prop_find(spa, ZPOOL_PROP_AUTOREPLACE, &autoreplace);
Expand Down

0 comments on commit da27b8b

Please sign in to comment.