mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] opl3: Fix a possible sleep-in-atomic bug in snd_opl3_find_patch
@ 2017-10-09  2:35 Jia-Ju Bai
  2017-10-09  6:32 ` [alsa-devel] " Clemens Ladisch
  0 siblings, 1 reply; 3+ messages in thread
From: Jia-Ju Bai @ 2017-10-09  2:35 UTC (permalink / raw)
  To: perex, tiwai, o-takashi, elfring, fabf
  Cc: alsa-devel, linux-kernel, Jia-Ju Bai

The driver may sleep under a spinlock, and the function call path is:
snd_opl3_note_on (acquire the spinlock)
  snd_opl3_find_patch
    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 <baijiaju1990@163.com>
---
 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;
-- 
1.7.9.5

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [alsa-devel] [PATCH] opl3: Fix a possible sleep-in-atomic bug in snd_opl3_find_patch
  2017-10-09  2:35 [PATCH] opl3: Fix a possible sleep-in-atomic bug in snd_opl3_find_patch Jia-Ju Bai
@ 2017-10-09  6:32 ` Clemens Ladisch
  2017-10-09  7:51   ` Jia-Ju Bai
  0 siblings, 1 reply; 3+ messages in thread
From: Clemens Ladisch @ 2017-10-09  6:32 UTC (permalink / raw)
  To: Jia-Ju Bai
  Cc: perex, tiwai, o-takashi, elfring, fabf, alsa-devel, linux-kernel

Jia-Ju Bai wrote:
> The driver may sleep under a spinlock, and the function call path is:
> snd_opl3_note_on (acquire the spinlock)
>   snd_opl3_find_patch
>     kzalloc(GFP_KERNEL) --> may sleep

This call path is not possible because create_patch is not set.


Regards,
Clemens

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [alsa-devel] [PATCH] opl3: Fix a possible sleep-in-atomic bug in snd_opl3_find_patch
  2017-10-09  6:32 ` [alsa-devel] " Clemens Ladisch
@ 2017-10-09  7:51   ` Jia-Ju Bai
  0 siblings, 0 replies; 3+ messages in thread
From: Jia-Ju Bai @ 2017-10-09  7:51 UTC (permalink / raw)
  To: Clemens Ladisch
  Cc: perex, tiwai, o-takashi, elfring, fabf, alsa-devel, linux-kernel

Thanks for your reply :)
Yes, you are right. Sorry for this false positive.


Thanks,
Jia-Ju Bai

On 2017/10/9 14:32, Clemens Ladisch wrote:
> Jia-Ju Bai wrote:
>> The driver may sleep under a spinlock, and the function call path is:
>> snd_opl3_note_on (acquire the spinlock)
>>    snd_opl3_find_patch
>>      kzalloc(GFP_KERNEL) --> may sleep
> This call path is not possible because create_patch is not set.
>
>
> Regards,
> Clemens

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-10-09  7:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-09  2:35 [PATCH] opl3: Fix a possible sleep-in-atomic bug in snd_opl3_find_patch Jia-Ju Bai
2017-10-09  6:32 ` [alsa-devel] " Clemens Ladisch
2017-10-09  7:51   ` Jia-Ju Bai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®