Skip to content

Commit 520ba72

Browse files
Minghao Chitorvalds
Minghao Chi
authored andcommitted
ipc/sem: do not sleep with a spin lock held
We can't call kvfree() with a spin lock held, so defer it. Link: https://lkml.kernel.org/r/20211223031207.556189-1-chi.minghao@zte.com.cn Fixes: fc37a3b ("[PATCH] ipc sem: use kvmalloc for sem_undo allocation") Reported-by: Zeal Robot <zealci@zte.com.cn> Signed-off-by: Minghao Chi <chi.minghao@zte.com.cn> Reviewed-by: Shakeel Butt <shakeelb@google.com> Reviewed-by: Manfred Spraul <manfred@colorfullife.com> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Yang Guang <cgel.zte@gmail.com> Cc: Davidlohr Bueso <dbueso@suse.de> Cc: Randy Dunlap <rdunlap@infradead.org> Cc: Bhaskar Chowdhury <unixbhaskar@gmail.com> Cc: Vasily Averin <vvs@virtuozzo.com> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 314c459 commit 520ba72

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

ipc/sem.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1964,6 +1964,7 @@ static struct sem_undo *find_alloc_undo(struct ipc_namespace *ns, int semid)
19641964
*/
19651965
un = lookup_undo(ulp, semid);
19661966
if (un) {
1967+
spin_unlock(&ulp->lock);
19671968
kvfree(new);
19681969
goto success;
19691970
}
@@ -1976,9 +1977,8 @@ static struct sem_undo *find_alloc_undo(struct ipc_namespace *ns, int semid)
19761977
ipc_assert_locked_object(&sma->sem_perm);
19771978
list_add(&new->list_id, &sma->list_id);
19781979
un = new;
1979-
1980-
success:
19811980
spin_unlock(&ulp->lock);
1981+
success:
19821982
sem_unlock(sma, -1);
19831983
out:
19841984
return un;

0 commit comments

Comments
 (0)