From 174e3868c0a0f178ada793c7049c5e388836f663 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Thu, 5 Feb 2004 17:57:20 +0100 Subject: [PATCH] ALSA CVS update - Jaroslav Kysela RawMidi Midlevel copy_*_user() function cannot be called from spinlock context --- sound/core/rawmidi.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c index e385c93318f0b..81be9e56a0bb3 100644 --- a/sound/core/rawmidi.c +++ b/sound/core/rawmidi.c @@ -909,10 +909,11 @@ static long snd_rawmidi_kernel_read1(snd_rawmidi_substream_t *substream, if (kernel) { memcpy(buf + result, runtime->buffer + runtime->appl_ptr, count1); } else { + spin_unlock_irqrestore(&runtime->lock, flags); if (copy_to_user(buf + result, runtime->buffer + runtime->appl_ptr, count1)) { - spin_unlock_irqrestore(&runtime->lock, flags); return result > 0 ? result : -EFAULT; } + spin_lock_irqsave(&runtime->lock, flags); } runtime->appl_ptr += count1; runtime->appl_ptr %= runtime->buffer_size; @@ -1133,10 +1134,13 @@ static long snd_rawmidi_kernel_write1(snd_rawmidi_substream_t * substream, const if (kernel) { memcpy(runtime->buffer + runtime->appl_ptr, buf, count1); } else { + spin_unlock_irqrestore(&runtime->lock, flags); if (copy_from_user(runtime->buffer + runtime->appl_ptr, buf, count1)) { + spin_lock_irqsave(&runtime->lock, flags); result = result > 0 ? result : -EFAULT; goto __end; } + spin_lock_irqsave(&runtime->lock, flags); } runtime->appl_ptr += count1; runtime->appl_ptr %= runtime->buffer_size; -- 2.53.0