Linux 6.1.49
[platform/kernel/linux-starfive.git] / ipc / sem.c
index c8496f9..00f88aa 100644 (file)
--- a/ipc/sem.c
+++ b/ipc/sem.c
@@ -2179,14 +2179,15 @@ long __do_semtimedop(int semid, struct sembuf *sops,
                 * scenarios where we were awakened externally, during the
                 * window between wake_q_add() and wake_up_q().
                 */
+               rcu_read_lock();
                error = READ_ONCE(queue.status);
                if (error != -EINTR) {
                        /* see SEM_BARRIER_2 for purpose/pairing */
                        smp_acquire__after_ctrl_dep();
+                       rcu_read_unlock();
                        goto out;
                }
 
-               rcu_read_lock();
                locknum = sem_lock(sma, sops, nsops);
 
                if (!ipc_valid_object(&sma->sem_perm))