NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
kern/58167: unnecessary mutex_tryenter in tap(4)
>Number: 58167
>Category: kern
>Synopsis: unnecessary mutex_tryenter in tap(4)
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: kern-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed Apr 17 18:50:01 +0000 2024
>Originator: Taylor R Campbell
>Release: current, 10, 9, 8, ...
>Organization:
The TryTAP Foundation
>Environment:
>Description:
875 /* In the TAP_NBIO case, we have to make sure we won't be sleeping */
876 if ((sc->sc_flags & TAP_NBIO) != 0) {
877 if (!mutex_tryenter(&sc->sc_lock))
878 return EWOULDBLOCK;
879 } else
880 mutex_enter(&sc->sc_lock);
https://nxr.netbsd.org/xref/src/sys/net/if_tap.c#875
This lock is only used to serialize access to the packet queue, not to serialize operations that sleep for I/O or anything -- it's a spin lock anyway (though I'm not sure there's any reason for it to be). So there is no need to make tap_dev_read flakier and harder to understand by using mutex_tryenter.
>How-To-Repeat:
code inspection
>Fix:
just use mutex_enter unconditionally
Home |
Main Index |
Thread Index |
Old Index