Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions sys/dev/sound/midi/midi.c
Original file line number Diff line number Diff line change
Expand Up @@ -658,21 +658,19 @@ midi_poll(struct cdev *i_dev, int events, struct thread *td)
mtx_lock(&m->lock);
mtx_lock(&m->qlock);

if (events & (POLLIN | POLLRDNORM))
if (events & (POLLIN | POLLRDNORM)) {
if (!MIDIQ_EMPTY(m->inq))
events |= events & (POLLIN | POLLRDNORM);

if (events & (POLLOUT | POLLWRNORM))
if (MIDIQ_AVAIL(m->outq) < m->hiwat)
events |= events & (POLLOUT | POLLWRNORM);

if (revents == 0) {
if (events & (POLLIN | POLLRDNORM))
revents |= events & (POLLIN | POLLRDNORM);
else
selrecord(td, &m->rsel);

if (events & (POLLOUT | POLLWRNORM))
}
if (events & (POLLOUT | POLLWRNORM)) {
if (MIDIQ_AVAIL(m->outq) < m->hiwat)
revents |= events & (POLLOUT | POLLWRNORM);
else
selrecord(td, &m->wsel);
}

mtx_unlock(&m->lock);
mtx_unlock(&m->qlock);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not related to the patch, but I'm pretty sure there is a lock order reversal here. Have you tested this code path? If there is, I can propose a patch. Let me know.

Copy link
Contributor Author

@n-p-soft n-p-soft Nov 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just swapped these unlocks, seems strange to me. Anyway let restore the right order.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can open a new PR for this issue.


Expand Down
Loading