[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210306141106.18695-1-baijiaju1990@gmail.com>
Date: Sat, 6 Mar 2021 06:11:06 -0800
From: Jia-Ju Bai <baijiaju1990@...il.com>
To: rui.zhang@...el.com, daniel.lezcano@...aro.org, amitk@...nel.org
Cc: linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org,
Jia-Ju Bai <baijiaju1990@...il.com>
Subject: [PATCH] thermal: thermal_of: fix error return code of thermal_of_populate_bind_params()
When kcalloc() fails and __tcbp is NULL, no error return code of
thermal_of_populate_bind_params() is assigned.
To fix this bug, ret is assigned with -ENOMEM in this case.
Reported-by: TOTE Robot <oslab@...nghua.edu.cn>
Signed-off-by: Jia-Ju Bai <baijiaju1990@...il.com>
---
drivers/thermal/thermal_of.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c
index 69ef12f852b7..e8c9041482e9 100644
--- a/drivers/thermal/thermal_of.c
+++ b/drivers/thermal/thermal_of.c
@@ -710,8 +710,10 @@ static int thermal_of_populate_bind_params(struct device_node *np,
}
__tcbp = kcalloc(count, sizeof(*__tcbp), GFP_KERNEL);
- if (!__tcbp)
+ if (!__tcbp) {
+ ret = -ENOMEM;
goto end;
+ }
for (i = 0; i < count; i++) {
ret = of_parse_phandle_with_args(np, "cooling-device",
--
2.17.1
Powered by blists - more mailing lists