Linux Operating System Source Code: IBM Patches

 
Indydog driver race fix
Description:
Fixes a race in the indydog watchdog driver.
Developer:
Dave Hansen
Status:
Included in project
Release Included:
Accepted by driver maintainer; Should be included in 2.4.19-pre5

Notes:

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.

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.

Release Notes Date Files
2.4.19 Release Notes 2002-03-27  
  File Notes   indydog.bklfix.2.4.19-pre4.patch.gz