[U-Boot] [PATCH v3 02/15] sysreset-uclass: ensure udevice is probed before requesting reset

Simon Glass sjg at chromium.org
Thu Apr 20 00:12:17 UTC 2017


Hi Alvaro,

On 19 April 2017 at 15:25, Simon Glass <sjg at chromium.org> wrote:
> Hi Alvaro,
>
> On 19 April 2017 at 03:18, Álvaro Fernández Rojas <noltari at gmail.com> wrote:
>> This is what I think it's going on:
>>
>> sysreset_walk():
>> - calls uclass_first_device():
>> - Calls uclass_find_first_device():
>> - device is found.
>> - ret is set to 0.
>> - Calls uclass_get_device_tail():
>> - ret == 0 -> doesn't return.
>> - dev != null -> assert is true.
>> - Calls device_probe():
>> - It fails *somewhere* and goes to fail WITHOUT setting dev to NULL.
>> - ret != 0 -> returns without setting devp = dev.
>> - dev is NOT NULL but device is not probed.
>> - Tries to get ops from a not probed device -> Exception.
>>
>>
>> So basically it's a bug related to device_probe not nulling dev when failing
>> and sysreset_walk() checking only if the device is not null and not the
>> actual return of uclass_first_device() and uclass_next_device()...
>
> OK thanks for the explanation. Yes this is a bug and there are no
> tests to catch it.
>
> In this case uclass_first/next_device() should return dev = NULL.
>
> I'll take a look and see if I can create a few patches.

Nope, I'm still confused.

sysreset_walk() should receive dev = NULL in this case and exit. I
still don't understand how this exception happens.

You can see *devp being set to NULL in both uclass_first_device() and
uclass_next_device().

Regards,
Simon


More information about the U-Boot mailing list