Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

thermal:core:fix: Check return code of the ->get_max_state() callback

The return code from ->get_max_state() callback was not checked during
binding cooling device to thermal zone device.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>

authored by

Lukasz Majewski and committed by
Eduardo Valentin
9a3031dc 73904cbc

+4 -2
+4 -2
drivers/thermal/thermal_core.c
··· 928 928 struct thermal_zone_device *pos1; 929 929 struct thermal_cooling_device *pos2; 930 930 unsigned long max_state; 931 - int result; 931 + int result, ret; 932 932 933 933 if (trip >= tz->trips || (trip < 0 && trip != THERMAL_TRIPS_NONE)) 934 934 return -EINVAL; ··· 945 945 if (tz != pos1 || cdev != pos2) 946 946 return -EINVAL; 947 947 948 - cdev->ops->get_max_state(cdev, &max_state); 948 + ret = cdev->ops->get_max_state(cdev, &max_state); 949 + if (ret) 950 + return ret; 949 951 950 952 /* lower default 0, upper default max_state */ 951 953 lower = lower == THERMAL_NO_LIMIT ? 0 : lower;