• Hsin-Yi Wang's avatar
    PM: domains: Ensure genpd_debugfs_dir exists before remove · 37101d3c
    Hsin-Yi Wang authored
    Both genpd_debug_add() and genpd_debug_remove() may be called
    indirectly by other drivers while genpd_debugfs_dir is not yet
    set. For example, drivers can call pm_genpd_init() in probe or
    pm_genpd_init() in probe fail/cleanup path:
    
    pm_genpd_init()
     --> genpd_debug_add()
    
    pm_genpd_remove()
     --> genpd_remove()
       --> genpd_debug_remove()
    
    At this time, genpd_debug_init() may not yet be called.
    
    genpd_debug_add() checks that if genpd_debugfs_dir is NULL, it
    will return directly. Make sure this is also checked
    in pm_genpd_remove(), otherwise components under debugfs root
    which has the same name as other components under pm_genpd may
    be accidentally removed, since NULL represents debugfs root.
    
    Fixes: 718072ce
    
     ("PM: domains: create debugfs nodes when adding power domains")
    Signed-off-by: default avatarHsin-Yi Wang <hsinyi@chromium.org>
    Reviewed-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno...
    37101d3c
domain.c 84.9 KB