[U-Boot] [PATCH v1] tpm: Fix uclass_first_device error handling

Mario Six mario.six at gdsys.cc
Tue Apr 5 14:35:22 CEST 2016


Hi Simon,

Quoting Simon Glass <sjg at chromium.org>:

> Hi Mario,
>
> On 30 March 2016 at 02:22, Mario Six <mario.six at gdsys.cc> wrote:
>> uclass_first_device might return NULL for the device despite a zero
>> return code. Currently, this might lead to null pointer dereferencing,
>> since the returned device is not properly checked.
>>
>> Hence, always check if the device returned from uclass_first_device is
>> NULL and return -ENODEV if it is.
>>
>> Signed-off-by: Mario Six <mario.six at gdsys.cc>
>> ---
>>  lib/tpm.c | 6 +++++-
>>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> Thanks for the patch. But can you please use uclass_first_device_err()?
>
> Regards,
> Simon

Yes, of course; sorry, I was not aware of uclass_first_device_err. That's a
much nicer solution :-)

I'll prepare a v2 shortly.

Best regards,

Mario



More information about the U-Boot mailing list