Patch "opp: Prevent memory leak in dev_pm_opp_attach_genpd()" has been added to the 5.8-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    opp: Prevent memory leak in dev_pm_opp_attach_genpd()

to the 5.8-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     opp-prevent-memory-leak-in-dev_pm_opp_attach_genpd.patch
and it can be found in the queue-5.8 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit b0658cd9025514ee97cad3d50434c9f3e55979ae
Author: Viresh Kumar <viresh.kumar@xxxxxxxxxx>
Date:   Mon Aug 31 11:22:37 2020 +0530

    opp: Prevent memory leak in dev_pm_opp_attach_genpd()
    
    [ Upstream commit cb60e9602cce1593eb1e9cdc8ee562815078a354 ]
    
    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: Stephan Gerhold <stephan@xxxxxxxxxxx>
    Signed-off-by: Viresh Kumar <viresh.kumar@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/opp/core.c b/drivers/opp/core.c
index 91dcad982d362..11d192fb2e813 100644
--- a/drivers/opp/core.c
+++ b/drivers/opp/core.c
@@ -1918,6 +1918,9 @@ static void _opp_detach_genpd(struct opp_table *opp_table)
 {
 	int index;
 
+	if (!opp_table->genpd_virt_devs)
+		return;
+
 	for (index = 0; index < opp_table->required_opp_count; index++) {
 		if (!opp_table->genpd_virt_devs[index])
 			continue;
@@ -1964,6 +1967,9 @@ struct opp_table *dev_pm_opp_attach_genpd(struct device *dev,
 	if (!opp_table)
 		return ERR_PTR(-ENOMEM);
 
+	if (opp_table->genpd_virt_devs)
+		return opp_table;
+
 	/*
 	 * If the genpd's OPP table isn't already initialized, parsing of the
 	 * required-opps fail for dev. We should retry this after genpd's OPP



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux