Re: [PATCH 1/5] driver core: Add simple parameter checks for APIs device_(for_each|find)_child()
From: quic_zijuhu
Date: Tue Aug 13 2024 - 06:01:30 EST
On 8/13/2024 5:44 PM, Greg Kroah-Hartman wrote:
> On Sun, Aug 11, 2024 at 08:18:07AM +0800, Zijun Hu wrote:
>> From: Zijun Hu <quic_zijuhu@xxxxxxxxxxx>
>>
>> Add simple parameter checks for APIs device_(for_each|find)_child() and
>> device_for_each_child_reverse().
>
> Ok, but why? Who is calling this with NULL as a parent pointer?
>
> Remember, changelog text describes _why_ not just _what_ you are doing.
>
For question why ?
The main purpose of this change is to make these APIs have *CONSISTENT*
parameter checking (!parent || !parent->p)
currently, 2 of them have checking (!parent->p), the other have checking
(!parent), the are INCONSISTENT.
For question who ?
device_find_child() have had such checking (!parent), that maybe mean
original author has concern that parent may be NULL.
Moreover, these are core driver APIs, it is worthy checking input
parameter strictly.
will correct commit message with v2.
> thanks,
>
> greg k-h