From 648a6f4495b183d4e0d8983ff768facb9a2185bb Mon Sep 17 00:00:00 2001 From: Sebastian Ott Date: Thu, 26 Oct 2017 16:36:45 +0200 Subject: [PATCH] s390/qdio: use atomic_cmpxchg qdio uses atomic_read to find an unused indicator and atomic_set to flag it as used. This could lead to multiple users getting the same indicator. Use atomic_cmpxchg instead. Signed-off-by: Sebastian Ott Acked-by: Ursula Braun Signed-off-by: Martin Schwidefsky --- drivers/s390/cio/qdio_thinint.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/s390/cio/qdio_thinint.c b/drivers/s390/cio/qdio_thinint.c index c61164f..3e587bf 100644 --- a/drivers/s390/cio/qdio_thinint.c +++ b/drivers/s390/cio/qdio_thinint.c @@ -56,10 +56,8 @@ static u32 *get_indicator(void) int i; for (i = 0; i < TIQDIO_NR_NONSHARED_IND; i++) - if (!atomic_read(&q_indicators[i].count)) { - atomic_set(&q_indicators[i].count, 1); + if (!atomic_cmpxchg(&q_indicators[i].count, 0, 1)) return &q_indicators[i].ind; - } /* use the shared indicator */ atomic_inc(&q_indicators[TIQDIO_SHARED_IND].count); -- 2.7.4