[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <c90b53af-1641-4c8a-97d9-27feed7b2a7d@linaro.org>
Date: Wed, 21 Aug 2024 12:49:30 +0200
From: Daniel Lezcano <daniel.lezcano@...aro.org>
To: "lihuisong (C)" <lihuisong@...wei.com>,
"Rafael J. Wysocki" <rjw@...ysocki.net>
Cc: LKML <linux-kernel@...r.kernel.org>, Lukasz Luba <lukasz.luba@....com>,
Zhang Rui <rui.zhang@...el.com>, Linux PM <linux-pm@...r.kernel.org>
Subject: Re: [PATCH v3 02/14] thermal: core: Rearrange checks in
thermal_bind_cdev_to_trip()
On 21/08/2024 11:44, lihuisong (C) wrote:
>
> 在 2024/8/21 17:28, Daniel Lezcano 写道:
>> On 21/08/2024 10:49, lihuisong (C) wrote:
>>
>> [ ... ]
>>
>>>> - list_for_each_entry(pos2, &thermal_cdev_list, node) {
>>>> - if (pos2 == cdev)
>>>> - break;
>>>> - }
>>>> + lockdep_assert_held(&thermal_list_lock);
>>>> - if (tz != pos1 || cdev != pos2)
>>>> + if (list_empty(&tz->node) || list_empty(&cdev->node))
>>> The old verification is ensure that tz and cdev already add to
>>> thermal_tz_list and thermal_cdev_list,respectively.
>>> Namely, tz and cdev are definitely registered and intialized.
>>> The check is ok for all untizalized thermal_zone_device and cooling
>>> device.
>>> But the new verification doesn't seem to do that.
>>
>> If the tz or the cdev are registered then their "->node" is not empty
>> because they are linked with the thermal_list and cdev_list
>>
>> So either way is browsing the lists to find the tz/cdev or just check
>> "->node" is not empty. The latter the faster.
> Assume that tz/cdev isn't intiazlized and registered to thermal_tz_list
> or thermal_cdev_list. And then directly call this interface.
Then there is a bug in the internal code because the
thermal_zone_device_register*() and cooling_device_device_register()
allocate and initialize those structures.
The caller of the function is supposed to use the API provided by the
thermal framework. It is not possible to plan every stupid things a
driver can do. In this particular case, very likely the kernel will
crash immediately which is a sufficient test for me and coercive enough
to have the API user to put its code in question ;)
--
<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
Powered by blists - more mailing lists