Skip to content

Commit

Permalink
ipc/sem: do not sleep with a spin lock held
Browse files Browse the repository at this point in the history
We can't call kvfree() with a spin lock held, so defer it.

Link: https://lkml.kernel.org/r/[email protected]
Fixes: fc37a3b ("[PATCH] ipc sem: use kvmalloc for sem_undo allocation")
Reported-by: Zeal Robot <[email protected]>
Signed-off-by: Minghao Chi <[email protected]>
Reviewed-by: Shakeel Butt <[email protected]>
Reviewed-by: Manfred Spraul <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: Yang Guang <[email protected]>
Cc: Davidlohr Bueso <[email protected]>
Cc: Randy Dunlap <[email protected]>
Cc: Bhaskar Chowdhury <[email protected]>
Cc: Vasily Averin <[email protected]>
Cc: <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Minghao Chi authored and torvalds committed Feb 4, 2022
1 parent 314c459 commit 520ba72
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ipc/sem.c
Original file line number Diff line number Diff line change
Expand Up @@ -1964,6 +1964,7 @@ static struct sem_undo *find_alloc_undo(struct ipc_namespace *ns, int semid)
*/
un = lookup_undo(ulp, semid);
if (un) {
spin_unlock(&ulp->lock);
kvfree(new);
goto success;
}
Expand All @@ -1976,9 +1977,8 @@ static struct sem_undo *find_alloc_undo(struct ipc_namespace *ns, int semid)
ipc_assert_locked_object(&sma->sem_perm);
list_add(&new->list_id, &sma->list_id);
un = new;

success:
spin_unlock(&ulp->lock);
success:
sem_unlock(sma, -1);
out:
return un;
Expand Down

0 comments on commit 520ba72

Please sign in to comment.