ces_entered should be put in a critical section to avoid race condition.

Signed-off-by: WANG Chao <[email protected]>
---
 drivers/ras/cec.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/ras/cec.c b/drivers/ras/cec.c
index 2e0bf1269c31..702e4c02c713 100644
--- a/drivers/ras/cec.c
+++ b/drivers/ras/cec.c
@@ -286,10 +286,10 @@ int cec_add_elem(u64 pfn)
        if (!ce_arr.array || ce_arr.disabled)
                return -ENODEV;
 
-       ca->ces_entered++;
-
        mutex_lock(&ce_mutex);
 
+       ca->ces_entered++;
+
        if (ca->n == MAX_ELEMS)
                WARN_ON(!del_lru_elem_unlocked(ca));
 
-- 
2.21.0

Reply via email to