• Alexander Shishkin's avatar
    stm class: Fix a use-after-free · 3ff8bc81
    Alexander Shishkin authored
    commit fd085bb1 upstream.
    
    For reasons unknown, the stm_source removal path uses device_destroy()
    to kill the underlying device object. Because device_destroy() uses
    devt to look for the device to destroy and the fact that stm_source
    devices don't have one (or all have the same one), it just picks the
    first device in the class, which may well be the wrong one.
    
    That is, loading stm_console and stm_heartbeat and then removing both
    will die in dereferencing a freed object.
    
    Since this should have been device_unregister() in the first place,
    use it instead of device_destroy().
    Signed-off-by: default avatarAlexander Shishkin <alexander.shishkin@linux.intel.com>
    Fixes: 7bd1d409 ("stm class: Introduce an abstraction for System Trace Module devices")
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    3ff8bc81
core.c 26.9 KB