Page MenuHomeFreeBSD

uart: fix sleeping while holding mutex in uart_tty_detach()
ClosedPublic

Authored by guest-seuros on Thu, Jan 29, 10:41 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Feb 13, 9:32 PM
Unknown Object (File)
Sun, Feb 8, 4:34 PM
Unknown Object (File)
Tue, Feb 3, 9:33 PM
Unknown Object (File)
Tue, Feb 3, 3:19 AM
Unknown Object (File)
Mon, Feb 2, 6:20 PM
Unknown Object (File)
Fri, Jan 30, 11:36 PM
Unknown Object (File)
Fri, Jan 30, 10:06 PM
Unknown Object (File)
Fri, Jan 30, 9:05 PM
Subscribers

Details

Summary

Move swi_remove() call before acquiring the tty lock. swi_remove() calls intr_event_remove_handler() which may sleep via msleep(), causing a lock order violation when called with the tty mutex held.

The software interrupt handler removal operates on the interrupt event structure independently and does not require the tty lock. This matches the pattern used in other drivers such as tcp_hpts.c where swi_remove() is called without holding other locks.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

guest-seuros held this revision as a draft.
guest-seuros added a reviewer: kevans.

I think this is good. I looked breifly, and swi_remove returns with the swi handler exited and won't be called again. Otherwise it looks deadlocky.

This revision is now accepted and ready to land.Sun, Feb 1, 9:39 PM

I'll go ahead and land this momentarily.

In D54953#1258064, @imp wrote:

I think this is good. I looked breifly, and swi_remove returns with the swi handler exited and won't be called again. Otherwise it looks deadlocky.

Yeah, when I looked at it in Discord I noted that there's probably nothing preventing the ithread from blocking on the tty lock, preventing the thread from transitioning to dead... not ideal.