Re: indydog driver race

Guido Guenther (
Wed, 27 Mar 2002 17:20:50 +0100

On Tue, Mar 26, 2002 at 10:01:40AM -0800, Dave Hansen wrote:
> indydog_open has a race
> indydog_open(struct inode *inode, struct file *file)
> {
> if( indydog_alive )
> return -EBUSY;
> ...
> indydog_alive = 1;
> return 0;
> }
> If 2 opens happen simultaneously, there can be 2 tasks which both see
> indydog_alive as 0 and both set it to 1, successfully opening the
> device. Block and char devices hold the BKL before calling the driver's
> open function, but misc devices don't do the same.
As Dave and me discussed in private mail this can't actually happen on
non-preemtible kernels since IP22 is non-SMP(which is why I didn't
bother when I wrote it). Anyway, a race is a race, no excuses.

> The BKL is not needed in the release function, as far as I can see.
> Alan's softdog.c driver uses atomic ops without BKL to do the same thing
> as your driver. Patch to fix attached.
Tested and works on Mips/IP22. Thanks again Dave,
-- Guido
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at