]> git.hungrycats.org Git - linux/commitdiff
ALSA CVS update
authorJaroslav Kysela <perex@suse.cz>
Wed, 25 Aug 2004 17:18:37 +0000 (19:18 +0200)
committerJaroslav Kysela <perex@suse.cz>
Wed, 25 Aug 2004 17:18:37 +0000 (19:18 +0200)
RawMidi Midlevel
fix handling of EFAULT errors in snd_rawmidi_read/write;
fix hang when writing to /dev/midi* with O_SYNC

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
sound/core/rawmidi.c

index 8004d5d2d45cda4877ff355434838c64fe7d0404..1c753cda66f4cd05d19273cd83d4a00f2dfd5f24 100644 (file)
@@ -984,6 +984,8 @@ static ssize_t snd_rawmidi_read(struct file *file, char __user *buf, size_t coun
                }
                spin_unlock_irq(&runtime->lock);
                count1 = snd_rawmidi_kernel_read1(substream, buf, count, 0);
+               if (count1 < 0)
+                       return result > 0 ? result : count1;
                result += count1;
                buf += count1;
                count -= count1;
@@ -1216,14 +1218,14 @@ static ssize_t snd_rawmidi_write(struct file *file, const char __user *buf, size
                spin_unlock_irq(&runtime->lock);
                count1 = snd_rawmidi_kernel_write1(substream, buf, count, 0);
                if (count1 < 0)
-                       continue;
+                       return result > 0 ? result : count1;
                result += count1;
                buf += count1;
                if ((size_t)count1 < count && (file->f_flags & O_NONBLOCK))
                        break;
                count -= count1;
        }
-       while (file->f_flags & O_SYNC) {
+       if (file->f_flags & O_SYNC) {
                spin_lock_irq(&runtime->lock);
                while (runtime->avail != runtime->buffer_size) {
                        wait_queue_t wait;