]> git.hungrycats.org Git - linux/commitdiff
ALSA CVS update - Jaroslav Kysela <perex@suse.cz>
authorJaroslav Kysela <perex@suse.cz>
Thu, 5 Feb 2004 16:57:20 +0000 (17:57 +0100)
committerJaroslav Kysela <perex@suse.cz>
Thu, 5 Feb 2004 16:57:20 +0000 (17:57 +0100)
RawMidi Midlevel
copy_*_user() function cannot be called from spinlock context

sound/core/rawmidi.c

index e385c93318f0be92bc3e1435d6a7ceff0e352c99..81be9e56a0bb316c534dfcbdc2ec3219dc5307c6 100644 (file)
@@ -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;