aboutsummaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
authorGeLiXin <[email protected]>2016-11-01 07:04:01 +0800
committerBrian Behlendorf <[email protected]>2016-10-31 16:04:01 -0700
commit4aafab91c5033e35217209d121f4c2fb83a8f690 (patch)
tree62dc43157ba781e45dcf960ada03a8d81f716d70 /module
parent9f38f81ca38e62bc31af1d4086e0f7a963644d38 (diff)
Fix coverity defects: CID 147509
CID 147509: Explicit null dereferenced - l2arc_sublist_lock is fragile as relied on caller too much. Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: GeLiXin <[email protected]> Closes #5319
Diffstat (limited to 'module')
-rw-r--r--module/zfs/arc.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/module/zfs/arc.c b/module/zfs/arc.c
index 0c5e66cbe..5825d3300 100644
--- a/module/zfs/arc.c
+++ b/module/zfs/arc.c
@@ -919,6 +919,12 @@ uint64_t zfs_crc64_table[256];
#define L2ARC_FEED_SECS 1 /* caching interval secs */
#define L2ARC_FEED_MIN_MS 200 /* min caching interval ms */
+/*
+ * We can feed L2ARC from two states of ARC buffers, mru and mfu,
+ * and each of the state has two types: data and metadata.
+ */
+#define L2ARC_FEED_TYPES 4
+
#define l2arc_writes_sent ARCSTAT(arcstat_l2_writes_sent)
#define l2arc_writes_done ARCSTAT(arcstat_l2_writes_done)
@@ -6965,7 +6971,7 @@ l2arc_sublist_lock(int list_num)
multilist_t *ml = NULL;
unsigned int idx;
- ASSERT(list_num >= 0 && list_num <= 3);
+ ASSERT(list_num >= 0 && list_num < L2ARC_FEED_TYPES);
switch (list_num) {
case 0:
@@ -6980,6 +6986,8 @@ l2arc_sublist_lock(int list_num)
case 3:
ml = &arc_mru->arcs_list[ARC_BUFC_DATA];
break;
+ default:
+ return (NULL);
}
/*
@@ -7138,10 +7146,12 @@ l2arc_write_buffers(spa_t *spa, l2arc_dev_t *dev, uint64_t target_sz)
/*
* Copy buffers for L2ARC writing.
*/
- for (try = 0; try <= 3; try++) {
+ for (try = 0; try < L2ARC_FEED_TYPES; try++) {
multilist_sublist_t *mls = l2arc_sublist_lock(try);
uint64_t passed_sz = 0;
+ VERIFY3P(mls, !=, NULL);
+
/*
* L2ARC fast warmup.
*