mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-27 19:29:37 +00:00
thermal: thermal_of: Fix error return code of thermal_of_populate_bind_params()
[ Upstream commit45c7eaeb29
] When kcalloc() returns NULL to __tcbp or of_count_phandle_with_args() returns zero or -ENOENT to count, no error return code of thermal_of_populate_bind_params() is assigned. To fix these bugs, ret is assigned with -ENOMEM and -ENOENT in these cases, respectively. Fixes:a92bab8919
("of: thermal: Allow multiple devices to share cooling map") Reported-by: TOTE Robot <oslab@tsinghua.edu.cn> Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Link: https://lore.kernel.org/r/20210310122423.3266-1-baijiaju1990@gmail.com Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
f599960166
commit
f49f00dbe3
1 changed files with 5 additions and 2 deletions
|
@ -712,14 +712,17 @@ static int thermal_of_populate_bind_params(struct device_node *np,
|
|||
|
||||
count = of_count_phandle_with_args(np, "cooling-device",
|
||||
"#cooling-cells");
|
||||
if (!count) {
|
||||
if (count <= 0) {
|
||||
pr_err("Add a cooling_device property with at least one device\n");
|
||||
ret = -ENOENT;
|
||||
goto end;
|
||||
}
|
||||
|
||||
__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",
|
||||
|
|
Loading…
Reference in a new issue