[lkml]   [2017]   [Oct]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[PATCH] opl3: Fix a possible sleep-in-atomic bug in snd_opl3_find_patch
The driver may sleep under a spinlock, and the function call path is:
snd_opl3_note_on (acquire the spinlock)
kzalloc(GFP_KERNEL) --> may sleep

To fix it, GFP_KERNEL is replaced with GFP_ATOMIC.
This bug is found by my static analysis tool and my code review.

Signed-off-by: Jia-Ju Bai <>
sound/drivers/opl3/opl3_synth.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/drivers/opl3/opl3_synth.c b/sound/drivers/opl3/opl3_synth.c
index ddcc1a3..2e1cb2b 100644
--- a/sound/drivers/opl3/opl3_synth.c
+++ b/sound/drivers/opl3/opl3_synth.c
@@ -325,7 +325,7 @@ struct fm_patch *snd_opl3_find_patch(struct snd_opl3 *opl3, int prog, int bank,
if (!create_patch)
return NULL;

- patch = kzalloc(sizeof(*patch), GFP_KERNEL);
+ patch = kzalloc(sizeof(*patch), GFP_ATOMIC);
if (!patch)
return NULL;
patch->prog = prog;

 \ /
  Last update: 2017-10-09 04:34    [W:0.044 / U:1.248 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site