Re: [PATCH v2] thermal: Fix a NULL pointer dereference

From: Daniel Lezcano
Date: Wed Oct 06 2021 - 05:40:05 EST


On 06/10/2021 00:09, Subbaraman Narayanamurthy wrote:

[ ... ]

>>> The tests can be replaced by (!data->ops), no ?
>> Thanks Daniel for reviewing the patch.
>>
>> I agree that even if a sensor module is unregistered, that would call
>> "thermal_zone_of_sensor_unregister" which would eventually set NULL on
>> get_temp() and get_trend() and "tzd->ops" as well.
>>
>> However, of_thermal_get_temp() is trying to call "data->ops->get_temp"
>> which comes from a sensor driver when it registers. There is no
>> guarantee that it would be non-NULL right?
>>
>> Thinking of which, I think having both checks would be valid.
>
> Hi Daniel,
> Do you still have any concerns with this change?

Yes, let me answer to the initial patch.


--
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog