diff options
author | Richard Yao <[email protected]> | 2014-04-22 23:18:17 -0400 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2014-09-23 10:32:45 -0700 |
commit | 485c581c41c4da15a17f045605ce5a7562b3b8a2 (patch) | |
tree | fbf3828260c5b8a878f6f021dfa364a6e39de037 /module | |
parent | 928ee9fe184572a50e686b0c5173edb1b538c627 (diff) |
Fix function call with uninitialized value in vdev_inuse
LLVM's static analyzer reported that we could pass an uninitialized
pool_guid to spa_by_guid() in vdev_inuse(). Upon review, it is correct.
An attempt to repurpose a spare or L2ARC drive from an exported pool
will cause the pool_guid passed to spa_by_guid() to be unintialized
information from the stack. This will cause non-deterministic behavior.
Since there is no reason why we cannot repurpose such disks, we modify
vdev_inuse() to avoid calling spa_by_guid() when they are detected.
Signed-off-by: Richard Yao <[email protected]>
Signed-off-by: Brian Behlendorf <[email protected]>
Issue #2330
Diffstat (limited to 'module')
-rw-r--r-- | module/zfs/vdev_label.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/module/zfs/vdev_label.c b/module/zfs/vdev_label.c index 0780bf601..1c2f00fe2 100644 --- a/module/zfs/vdev_label.c +++ b/module/zfs/vdev_label.c @@ -599,7 +599,8 @@ vdev_inuse(vdev_t *vd, uint64_t crtxg, vdev_labeltype_t reason, * read-only. Instead we look to see if the pools is marked * read-only in the namespace and set the state to active. */ - if ((spa = spa_by_guid(pool_guid, device_guid)) != NULL && + if (state != POOL_STATE_SPARE && state != POOL_STATE_L2CACHE && + (spa = spa_by_guid(pool_guid, device_guid)) != NULL && spa_mode(spa) == FREAD) state = POOL_STATE_ACTIVE; |