Unverified Commit b263c203 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!10320 thermal: Fix NULL pointer dereferences in of_thermal_ functions

parents b9076769 1e33f9e0
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -77,7 +77,7 @@ static int of_thermal_get_temp(struct thermal_zone_device *tz,
{
	struct __thermal_zone *data = tz->devdata;

	if (!data->ops->get_temp)
	if (!data->ops || !data->ops->get_temp)
		return -EINVAL;

	return data->ops->get_temp(data->sensor_data, temp);
@@ -174,6 +174,10 @@ static int of_thermal_set_emul_temp(struct thermal_zone_device *tz,
{
	struct __thermal_zone *data = tz->devdata;

	if (!data->ops || !data->ops->set_emul_temp)
		return -EINVAL;


	return data->ops->set_emul_temp(data->sensor_data, temp);
}

@@ -182,7 +186,7 @@ static int of_thermal_get_trend(struct thermal_zone_device *tz, int trip,
{
	struct __thermal_zone *data = tz->devdata;

	if (!data->ops->get_trend)
	if (!data->ops || !data->ops->get_trend)
		return -EINVAL;

	return data->ops->get_trend(data->sensor_data, trip, trend);
@@ -310,7 +314,7 @@ static int of_thermal_set_trip_temp(struct thermal_zone_device *tz, int trip,
	if (trip >= data->ntrips || trip < 0)
		return -EDOM;

	if (data->ops->set_trip_temp) {
	if (data->ops && data->ops->set_trip_temp) {
		int ret;

		ret = data->ops->set_trip_temp(data->sensor_data, trip, temp);