From: "Chen-Yu Tsai (Moxa)" <wens@csie.org>
To: nobuhiro1.iwamatsu@toshiba.co.jp, pavel@denx.de
Cc: cip-dev@lists.cip-project.org, JohnsonCH.Chen@moxa.com,
victor.yu@moxa.com, wens@csie.org
Subject: [cip-dev] [PATCH 4.4.y-cip 06/11] cpufreq: ti-cpufreq: kfree opp_data when failure
Date: Wed, 9 Sep 2020 12:42:28 +0800 [thread overview]
Message-ID: <20200909044233.4115-7-wens@csie.org> (raw)
In-Reply-To: <20200909044233.4115-1-wens@csie.org>
[-- Attachment #1: Type: text/plain, Size: 2275 bytes --]
From: Zumeng Chen <zumeng.chen@gmail.com>
commit 05829d9431df1bf6de98679fbcfbad282c1c55a4 upstream.
memory leakage was found by kmemleak. opp_data needs to be freed
when failure, including fail_put_node.
unreferenced object 0xccdd4c40 (size 64):
comm "swapper", pid 1, jiffies 4294938465 (age 888.520s)
hex dump (first 32 bytes):
00 7c 00 c1 98 69 d8 ce 00 24 03 ce 00 24 03 ce .|...i...$...$..
20 35 23 c1 00 00 00 00 00 00 00 00 00 00 00 00 5#.............
backtrace:
[<c028fb64>] kmem_cache_alloc_trace+0x2c4/0x3cc
[<c076d5f0>] ti_cpufreq_probe+0x6c/0x334
[<c068d6e4>] platform_drv_probe+0x60/0xc0
[<c068b384>] driver_probe_device+0x218/0x2c4
[<c068b5a4>] __device_attach_driver+0xa8/0xdc
[<c0689340>] bus_for_each_drv+0x70/0xa4
[<c068b020>] __device_attach+0xc0/0x124
[<c068b634>] device_initial_probe+0x1c/0x20
[<c068a3b8>] bus_probe_device+0x94/0x9c
[<c0688300>] device_add+0x404/0x590
[<c068d408>] platform_device_add+0x11c/0x230
[<c068df40>] platform_device_register_full+0x10c/0x128
[<c076d578>] ti_cpufreq_init+0x44/0x50
[<c01017c4>] do_one_initcall+0x54/0x180
[<c0e00fe0>] kernel_init_freeable+0x270/0x33c
[<c093f2bc>] kernel_init+0x18/0x124
Signed-off-by: Zumeng Chen <zumeng.chen@gmail.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Chen-Yu Tsai (Moxa) <wens@csie.org>
---
drivers/cpufreq/ti-cpufreq.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/cpufreq/ti-cpufreq.c b/drivers/cpufreq/ti-cpufreq.c
index 1c63e96cba1f2..36627b2b256f8 100644
--- a/drivers/cpufreq/ti-cpufreq.c
+++ b/drivers/cpufreq/ti-cpufreq.c
@@ -217,7 +217,8 @@ static int ti_cpufreq_init(void)
opp_data->cpu_dev = get_cpu_device(0);
if (!opp_data->cpu_dev) {
pr_err("%s: Failed to get device for CPU0\n", __func__);
- return -ENODEV;
+ ret = ENODEV;
+ goto free_opp_data;
}
opp_data->opp_node = dev_pm_opp_of_get_opp_desc_node(opp_data->cpu_dev);
@@ -262,6 +263,8 @@ register_cpufreq_dt:
fail_put_node:
of_node_put(opp_data->opp_node);
+free_opp_data:
+ kfree(opp_data);
return ret;
}
--
2.28.0
[-- Attachment #2: Type: text/plain, Size: 419 bytes --]
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#5430): https://lists.cip-project.org/g/cip-dev/message/5430
Mute This Topic: https://lists.cip-project.org/mt/76726434/4520388
Group Owner: cip-dev+owner@lists.cip-project.org
Unsubscribe: https://lists.cip-project.org/g/cip-dev/leave/8129055/727948398/xyzzy [cip-dev@archiver.kernel.org]
-=-=-=-=-=-=-=-=-=-=-=-
next prev parent reply other threads:[~2020-09-09 4:44 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-09 4:42 [cip-dev] [PATCH 4.4.y-cip 00/11] ti-cpufreq backport Chen-Yu Tsai (Moxa)
2020-09-09 4:42 ` [cip-dev] [PATCH 4.4.y-cip 01/11] PM / OPP: Parse clock-latency and voltage-tolerance for v1 bindings Chen-Yu Tsai (Moxa)
2020-09-09 4:42 ` [cip-dev] [PATCH 4.4.y-cip 02/11] PM / OPP: Expose _of_get_opp_desc_node as dev_pm_opp API Chen-Yu Tsai (Moxa)
2020-09-09 4:42 ` [cip-dev] [PATCH 4.4.y-cip 03/11] Documentation: dt: add bindings for ti-cpufreq Chen-Yu Tsai (Moxa)
2020-09-09 4:42 ` [cip-dev] [PATCH 4.4.y-cip 04/11] cpufreq: ti: Add cpufreq driver to determine available OPPs at runtime Chen-Yu Tsai (Moxa)
2020-09-09 6:45 ` Pavel Machek
2020-09-09 7:03 ` Pavel Machek
2020-09-09 4:42 ` [cip-dev] [PATCH 4.4.y-cip 05/11] cpufreq: ti: Fix 'of_node_put' being called twice in error handling path Chen-Yu Tsai (Moxa)
2020-09-09 4:42 ` Chen-Yu Tsai (Moxa) [this message]
2020-09-09 4:42 ` [cip-dev] [PATCH 4.4.y-cip 07/11] cpufreq: ti-cpufreq: add missing of_node_put() Chen-Yu Tsai (Moxa)
2020-09-09 4:42 ` [cip-dev] [PATCH 4.4.y-cip 08/11] cpufreq: ti-cpufreq: Fix an incorrect error return value Chen-Yu Tsai (Moxa)
2020-09-09 4:42 ` [cip-dev] [PATCH 4.4.y-cip 09/11] cpufreq: dt: Don't use generic platdev driver for ti-cpufreq platforms Chen-Yu Tsai (Moxa)
2020-09-09 4:42 ` [cip-dev] [PATCH 4.4.y-cip 10/11] ARM: omap2plus_defconfig: Enable support for ti-cpufreq Chen-Yu Tsai (Moxa)
2020-09-09 4:42 ` [cip-dev] [PATCH 4.4.y-cip 11/11] ARM: dts: am33xx: Add updated operating-points-v2 table for cpu Chen-Yu Tsai (Moxa)
2020-09-09 7:03 ` [cip-dev] [PATCH 4.4.y-cip 00/11] ti-cpufreq backport Pavel Machek
2020-09-09 20:11 ` Nobuhiro Iwamatsu
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=20200909044233.4115-7-wens@csie.org \
--to=wens@csie.org \
--cc=JohnsonCH.Chen@moxa.com \
--cc=cip-dev@lists.cip-project.org \
--cc=nobuhiro1.iwamatsu@toshiba.co.jp \
--cc=pavel@denx.de \
--cc=victor.yu@moxa.com \
/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