Skip to content

Commit

Permalink
thermal: core: Fix TZ_GET_TRIP NULL pointer dereference
Browse files Browse the repository at this point in the history
commit 5838a14 upstream.

Do not call get_trip_hyst() from thermal_genl_cmd_tz_get_trip() if
the thermal zone does not define one.

Fixes: 1ce50e7 ("thermal: core: genetlink support for events/cmd/sampling")
Signed-off-by: Nicolas Cavallari <nicolas.cavallari@green-communications.fr>
Cc: 5.10+ <stable@vger.kernel.org> # 5.10+
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Nicolas Cavallari authored and gregkh committed Mar 8, 2022
1 parent a1753d5 commit 1c0b51e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/thermal/thermal_netlink.c
Expand Up @@ -418,11 +418,12 @@ static int thermal_genl_cmd_tz_get_trip(struct param *p)
for (i = 0; i < tz->trips; i++) {

enum thermal_trip_type type;
int temp, hyst;
int temp, hyst = 0;

tz->ops->get_trip_type(tz, i, &type);
tz->ops->get_trip_temp(tz, i, &temp);
tz->ops->get_trip_hyst(tz, i, &hyst);
if (tz->ops->get_trip_hyst)
tz->ops->get_trip_hyst(tz, i, &hyst);

if (nla_put_u32(msg, THERMAL_GENL_ATTR_TZ_TRIP_ID, i) ||
nla_put_u32(msg, THERMAL_GENL_ATTR_TZ_TRIP_TYPE, type) ||
Expand Down

0 comments on commit 1c0b51e

Please sign in to comment.