• Mike Leach's avatar
    coresight: configfs: Fix unload of configurations on module exit · 199380de
    Mike Leach authored
    Any loaded configurations must be correctly unloaded on coresight module
    exit, or issues can arise with nested locking in the configfs directory
    code if built with CONFIG_LOCKDEP.
    
    Prior to this patch, the preloaded configuration configfs directory entries
    were being unloaded by the recursive code in
    configfs_unregister_subsystem().
    
    However, when built with CONFIG_LOCKDEP, this caused a nested lock warning,
    which was not mitigated by the LOCKDEP dependent code in fs/configfs/dir.c
    designed to prevent this, due to the different directory levels for the
    root of the directory being removed.
    
    As the preloaded (and all other) configurations are registered after
    configfs_register_subsystem(), we now explicitly unload them before the
    call to configfs_unregister_subsystem().
    
    The new routine cscfg_unload_cfgs_on_exit() iterates through the load
    owner list to unload any remaining configurations that were not unloaded
    by the user before the module exits. This covers both the
    CSCFG_OWNER_PRELOAD and CSCFG_OWNER_MODULE owner types, and will be
    extended to cover future load owner types for CoreSight configurations.
    
    Fixes: eb2ec496
    
     ("coresight: syscfg: Update load API for config loadable modules")
    Reported-by: default avatarSuzuki Poulose <suzuki.poulose@arm.com>
    Signed-off-by: default avatarMike Leach <mike.leach@linaro.org>
    Reviewed-and-tested-by: default avatarSuzuki K Poulose <suzuki.poulose@arm.com>
    Link: https://lore.kernel.org/r/20220628173004.30002-2-mike.leach@linaro.org
    
    Signed-off-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
    199380de
coresight-syscfg.c 33.2 KB