• Viresh Kumar's avatar
    opp: Prevent memory leak in dev_pm_opp_attach_genpd() · cb60e960
    Viresh Kumar authored
    If dev_pm_opp_attach_genpd() is called multiple times (once for each CPU
    sharing the table), then it would result in unwanted behavior like
    memory leak, attaching the domain multiple times, etc.
    
    Handle that by checking and returning earlier if the domains are already
    attached. Now that dev_pm_opp_detach_genpd() can get called multiple
    times as well, we need to protect that too.
    
    Note that the virtual device pointers aren't returned in this case, as
    they may become unavailable to some callers during the middle of the
    operation.
    Reported-by: default avatarStephan Gerhold <stephan@gerhold.net>
    Signed-off-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
    cb60e960
core.c 63.5 KB