From f84d3d4735a1c96a745c453de8390936a7eb72d3 Mon Sep 17 00:00:00 2001 From: Sebastien Buisson Date: Thu, 25 Jul 2013 01:17:26 +0800 Subject: [PATCH] staging/lustre: fix 'data race condition' issues in at_reset() Fix 'data race condition' defects found by Coverity version 6.5.0: Data race condition (MISSING_LOCK) Accessing variable without holding lock. Elsewhere, this variable is accessed with lock held. at_reset() needs to take at->at_lock before modifying its members. Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-2744 Lustre-change: http://review.whamcloud.com/6569 Signed-off-by: Sebastien Buisson Reviewed-by: Bob Glossman Reviewed-by: Keith Mannthey Reviewed-by: Oleg Drokin Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/include/lustre_import.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/lustre/lustre/include/lustre_import.h b/drivers/staging/lustre/lustre/include/lustre_import.h index 3a5dd6a94c08..67259eb43cde 100644 --- a/drivers/staging/lustre/lustre/include/lustre_import.h +++ b/drivers/staging/lustre/lustre/include/lustre_import.h @@ -336,9 +336,11 @@ static inline unsigned int at_timeout2est(unsigned int val) } static inline void at_reset(struct adaptive_timeout *at, int val) { + spin_lock(&at->at_lock); at->at_current = val; at->at_worst_ever = val; at->at_worst_time = cfs_time_current_sec(); + spin_unlock(&at->at_lock); } static inline void at_init(struct adaptive_timeout *at, int val, int flags) { memset(at, 0, sizeof(*at)); -- 2.34.1