mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Navid Emamdoost <navid.emamdoost@gmail.com>
To: unlisted-recipients:; (no To-header on input)
Cc: emamd001@umn.edu, kjlu@umn.edu, smccaman@umn.edu,
	Navid Emamdoost <navid.emamdoost@gmail.com>,
	"Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Viresh Kumar <viresh.kumar@linaro.org>,
	linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] cpufreq/cpufreq_governor: Fix memory leak in cpufreq_dbs_governor_init
Date: Wed,  9 Oct 2019 18:26:42 -0500	[thread overview]
Message-ID: <20191009232643.20427-1-navid.emamdoost@gmail.com> (raw)

In the implementation of cpufreq_dbs_governor_init(), dbs_data is
allocated and later is assigned to governor_data. But before that
assignment, if gov->init() fails this allocation is not released.
dbs_data should be released in case if gov->init() failure.

Fixes: 714a2d9c8792 ("cpufreq: governor: split cpufreq_governor_dbs()")
Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
---
 drivers/cpufreq/cpufreq_governor.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
index 4bb054d0cb43..deb099d36266 100644
--- a/drivers/cpufreq/cpufreq_governor.c
+++ b/drivers/cpufreq/cpufreq_governor.c
@@ -428,8 +428,10 @@ int cpufreq_dbs_governor_init(struct cpufreq_policy *policy)
 	gov_attr_set_init(&dbs_data->attr_set, &policy_dbs->list);
 
 	ret = gov->init(dbs_data);
-	if (ret)
+	if (ret) {
+		kfree(dbs_data);
 		goto free_policy_dbs_info;
+	}
 
 	/*
 	 * The sampling interval should not be less than the transition latency
-- 
2.17.1


             reply	other threads:[~2019-10-09 23:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-09 23:26 Navid Emamdoost [this message]
2019-10-10  6:49 ` Viresh Kumar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191009232643.20427-1-navid.emamdoost@gmail.com \
    --to=navid.emamdoost@gmail.com \
    --cc=emamd001@umn.edu \
    --cc=kjlu@umn.edu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rjw@rjwysocki.net \
    --cc=smccaman@umn.edu \
    --cc=viresh.kumar@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®