[En-Nut-Discussion] Serious bug in Realtek driver - concerning RC 3.4.3

Pavel Chromy chromy at asix.cz
Mon Apr 19 21:29:35 CEST 2004


Hi All,

I discovered a serious bug in interrupt routine in Realtek driver -
have a look at this (important lines only):

cbi(EIMSK, RTL_SIGNAL_BIT);
sei();
NutEventPostAsync(&ni->ni_tx_rdy);
cli();
sbi(EIMSK, RTL_SIGNAL_BIT);        

That is, it enables interrupt and then calls NutEventPostAsync() with interrupts enabled,
which basicly works unsless some other interrupt routine is using the same technique.
In such case threads start dying, because of (I suppose) interrupted thread queue manipulation
which is (naturally) not reentrant.

I discovered this when programming my own driver for a device connected to external interrupt
pins and used nested interrupts the same way as realtek driver does.

When I surrounded NutEventPostAsync() by NutEnterCritical() and NutExitCritical()
or simply by cli() and sei() in my code, everything works perfectly.


The new VS1001 driver is also using nested interrupts, but it does not call any 
non-reentrant system functions though and thus it is not affected.

Although the driver works with the code in the distribution I consider this to be a bug
since it may conflict with similar user interrupt routines.


-- 
#define QUESTION ((bb)||!(bb))

Mgr. Pavel Chromy
ASIX s.r.o.
Staropramenna 4
150 00 Praha 5



More information about the En-Nut-Discussion mailing list