lkml.org 
[lkml]   [2020]   [Oct]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] iommu/rockchip: check return value of of_find_device_by_node() in rk_iommu_of_xlate()
From
Date

On 2020/10/29 21:51, Robin Murphy wrote:
> On 2020-10-29 13:19, yukuai (C) wrote:
>>
>> On 2020/10/29 18:08, Robin Murphy wrote:
>>> On 2020-10-29 09:22, Yu Kuai wrote:
>>>> If of_find_device_by_node() failed in rk_iommu_of_xlate(), null pointer
>>>> dereference will be triggered. Thus return error code if
>>>> of_find_device_by_node() failed.
>>>
>>> How can that happen? (Given that ".suppress_bind_attrs = true")
>>>
>>> Robin.
>>
>> I'm not sure if that could happen...
>>
>> My thought is that it's better to do such checking to aviod any possible
>> problem.
>
> ->of_xlate() is only invoked on the specific set of ops returned by
> iommu_ops_from_fwnode(). In turn, iommu_ops_from_fwnode() will only
> return those ops if the driver has successfully probed and called
> iommu_register_device() with the relevant DT node. For the driver to
> have been able to probe at all, a platform device associated with that
> DT node must have been created, and therefore of_find_device_by_node()
> cannot fail.
>
> If there ever were some problem serious enough to break that fundamental
> assumption, then I *want* these drivers to crash right here, with a nice
> clear stack trace to start debugging from. So no, I firmly disagree that
> adding redundant code, which will never do anything except attempt to
> paper over catastrophic memory corruption, is "better". Sorry :)
>

Sounds reasonable, thanks for your explanation

Yu Kuai

\
 
 \ /
  Last update: 2020-10-30 02:28    [W:0.039 / U:0.304 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site