1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-16 15:11:52 +00:00

Fixed locking bugs in rev.1.346:

(1) Don't attempt aquire the non-recursive lock sio_lock recursively.
    Doing so caused unbounded recursion in some setups.  E.g., if DDB,
    BREAK_TO_DEBUGGER and WITNESS are configured; if the debugger is
    entered using a break, then WITNESS will actually detect the invalid
    recursion and will add to it attempting to print a message about it.

(2) Don't use sio_lock before it has been initialized.  The old check
    (sio_inited != 0) didn't work when sio_inited was boolean because
    sio_inited was set too early, and became just wrong when sio_inited
    was changed to a tri-state variable in rev.1.348.

Reported and fixed in another way by:	fenner (1)
This commit is contained in:
Bruce Evans 2001-12-28 18:08:10 +00:00
parent be5fa99a1e
commit fb717773e7
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=88582

View File

@ -3092,6 +3092,7 @@ siocnputc(dev, c)
dev_t dev;
int c;
{
int need_unlock;
int s;
struct siocnstate sp;
Port_t iobase;
@ -3101,13 +3102,16 @@ siocnputc(dev, c)
else
iobase = siocniobase;
s = spltty();
if (sio_inited)
need_unlock = 0;
if (sio_inited == 2 && !mtx_owned(&sio_lock)) {
mtx_lock_spin(&sio_lock);
need_unlock = 1;
}
siocnopen(&sp, iobase, comdefaultrate);
siocntxwait(iobase);
outb(iobase + com_data, c);
siocnclose(&sp, iobase);
if (sio_inited)
if (need_unlock)
mtx_unlock_spin(&sio_lock);
splx(s);
}