--- rawmidi.c.old 2003-10-23 16:34:52.000000000 +0200 +++ rawmidi.c 2004-02-01 15:04:15.000000000 +0100 @@ -909,10 +909,11 @@ 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 @@ 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;