Skip to content

Commit

Permalink
thermal/drivers/ti-soc-thermal: Avoid dereferencing ERR_PTR
Browse files Browse the repository at this point in the history
On error the function ti_bandgap_get_sensor_data() returns the error
code in ERR_PTR() but we only checked if the return value is NULL or
not. And, so we can dereference an error code inside ERR_PTR.
While at it, convert a check to IS_ERR_OR_NULL.

Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Reviewed-by: Amit Kucheria <amit.kucheria@linaro.org>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20200424161944.6044-1-sudipm.mukherjee@gmail.com
  • Loading branch information
Sudip Mukherjee authored and Daniel Lezcano committed Apr 29, 2020
1 parent 770ae40 commit 7440f51
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drivers/thermal/ti-soc-thermal/ti-thermal-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ int ti_thermal_expose_sensor(struct ti_bandgap *bgp, int id,

data = ti_bandgap_get_sensor_data(bgp, id);

if (!data || IS_ERR(data))
if (!IS_ERR_OR_NULL(data))
data = ti_thermal_build_data(bgp, id);

if (!data)
Expand All @@ -196,7 +196,7 @@ int ti_thermal_remove_sensor(struct ti_bandgap *bgp, int id)

data = ti_bandgap_get_sensor_data(bgp, id);

if (data && data->ti_thermal) {
if (!IS_ERR_OR_NULL(data) && data->ti_thermal) {
if (data->our_zone)
thermal_zone_device_unregister(data->ti_thermal);
}
Expand Down Expand Up @@ -262,7 +262,7 @@ int ti_thermal_unregister_cpu_cooling(struct ti_bandgap *bgp, int id)

data = ti_bandgap_get_sensor_data(bgp, id);

if (data) {
if (!IS_ERR_OR_NULL(data)) {
cpufreq_cooling_unregister(data->cool_dev);
if (data->policy)
cpufreq_cpu_put(data->policy);
Expand Down

0 comments on commit 7440f51

Please sign in to comment.