midi_write() measures the free space in the queue, drops the lock to
copy from userland, and then appends what it copied. Two threads writing
in the same queue can both measure the same free space and both append,
overflowing the buffer, as M_TX only excludes a second open(2).
Append only as much as still fits after re-acquiring the lock, and give
the rest back to the uio, so that bytes do not get dropped silently.
Fixes: 6b69d6726a7d ("sound: Unlock around uiomove() in midi_{read,write}()")
MFC with: d63b11caae6c
Sponsored by: The FreeBSD Foundation