[PATCH 01/22] clk: check hw and hw->dev before dereference it
Claudiu.Beznea at microchip.com
Claudiu.Beznea at microchip.com
Tue Aug 4 09:19:15 CEST 2020
On 04.08.2020 05:00, Simon Glass wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
>
> Hi Claudiu,
>
> On Wed, 29 Jul 2020 at 08:51, Claudiu Beznea
> <claudiu.beznea at microchip.com> wrote:
>>
>> Check hw and hw->dev before dereference it.
>>
>> Signed-off-by: Claudiu Beznea <claudiu.beznea at microchip.com>
>> ---
>> drivers/clk/clk.c | 3 +++
>> 1 file changed, 3 insertions(+)
>>
>
> Why is this needed? It adds to code size and these situations should
> not occur. Perhaps use assert()?
In my debugging, investigating the issues that patches 03/22, 04/22, 06/22
try to address, I reached also this function and checked these pointers. In
the end the issue was not related to them but I though it might be useful
to keep these in a patch. I will remove it in the next version.
>
>> diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
>> index 0f55ba751c0f..9fa18e342eaf 100644
>> --- a/drivers/clk/clk.c
>> +++ b/drivers/clk/clk.c
>> @@ -57,6 +57,9 @@ ulong clk_generic_get_rate(struct clk *clk)
>>
>> const char *clk_hw_get_name(const struct clk *hw)
>> {
>> + if (!hw || !hw->dev)
>> + return NULL;
>> +
>> return hw->dev->name;
>> }
>>
>> --
>> 2.7.4
>>
>
> Regards,
> SImon
>
More information about the U-Boot
mailing list