• Tom Van Braeckel's avatar
    misc: pass miscdevice through file's private_data · 0b509d8d
    Tom Van Braeckel authored
    Make the miscdevice accessible through the file's private_data.
    
    Previously, this was done only when an open() file operation had been
    registered. If no custom open() file operation was defined,
    private_data was set to NULL.
    
    This subtle quirk was confusing, to the point where kernel code
    registered *empty* file open operations to have private_data point to
    the misc device structure and avoid duplicating that logic.
    
    And it could easily lead to bugs, where the addition or removal of a
    custom open() file operation surprisingly changes the initial value of
    a file's private_data structure.
    
    To resolve this, we now place the miscdevice in the file's private_data
    member unconditionally when open() is called.
    Signed-off-by: default avatarTom Van Braeckel <tomvanbraeckel@gmail.com>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    0b509d8d
misc.c 7.03 KB