Skip to content

Commit 45c7eae

Browse files
XidianGeneraldlezcano
authored andcommitted
thermal: thermal_of: Fix error return code of thermal_of_populate_bind_params()
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: a92bab8 ("of: thermal: Allow multiple devices to share cooling map") Reported-by: TOTE Robot <[email protected]> Signed-off-by: Jia-Ju Bai <[email protected]> Signed-off-by: Daniel Lezcano <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 7440e91 commit 45c7eae

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

drivers/thermal/thermal_of.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -704,14 +704,17 @@ static int thermal_of_populate_bind_params(struct device_node *np,
704704

705705
count = of_count_phandle_with_args(np, "cooling-device",
706706
"#cooling-cells");
707-
if (!count) {
707+
if (count <= 0) {
708708
pr_err("Add a cooling_device property with at least one device\n");
709+
ret = -ENOENT;
709710
goto end;
710711
}
711712

712713
__tcbp = kcalloc(count, sizeof(*__tcbp), GFP_KERNEL);
713-
if (!__tcbp)
714+
if (!__tcbp) {
715+
ret = -ENOMEM;
714716
goto end;
717+
}
715718

716719
for (i = 0; i < count; i++) {
717720
ret = of_parse_phandle_with_args(np, "cooling-device",

0 commit comments

Comments
 (0)