[PATCH 2/3] of/flattree: Fix crash when device tree absent

Grant Likely grant.likely at secretlab.ca
Mon Jul 19 14:37:09 EST 2010


On Sun, Jul 18, 2010 at 6:04 PM, Benjamin Herrenschmidt
<benh at kernel.crashing.org> wrote:
> On Wed, 2010-07-14 at 17:31 -0600, Grant Likely wrote:
>> This patch fixes the condition where device tree support is compiled
>> in, but no device tree was proved by firmware.  It makes
>> of_platform_bus_probe() explicitly check for a NULL device tree
>> pointer, and adds an error message if the device tree was unable
>> to be flattened.
>>
>> Signed-off-by: Grant Likely <grant.likely at secretlab.ca>
>
> Not sure about the message..

What do you mean?  On the draft ARM code, CONFIG_OF can be set, but no
device tree passed in.  As for the error message, I've removed that
from this patch (see below).

>
>> ---
>>  drivers/of/fdt.c      |    2 ++
>>  drivers/of/platform.c |    2 ++
>>  2 files changed, 4 insertions(+), 0 deletions(-)
>>
>> diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
>> index d61fda8..66401bc 100644
>> --- a/drivers/of/fdt.c
>> +++ b/drivers/of/fdt.c
>> @@ -94,6 +94,8 @@ int __init of_scan_flat_dt(int (*it)(unsigned long node,
>>                       break;
>>       } while (1);
>>
>> +     if (rc)
>> +             pr_err("Failed to unflatten device tree blob.  rc=%i\n", rc);
>>       return rc;
>>  }
>
> This is of_scan_flat_dt() ... might be better using something like
>
> "Failed to scan the flat device-tree (error %d)". Might also want to
> rate limit it to 1.

I've dropped this hunk anyway.  IIRC, I added this message to the
unflatten function, but it looks to have gotten mangled during a
rebase.  Anyway, there is no need for it right now, so I'll just write
a separate patch later if that changes.

g.


More information about the devicetree-discuss mailing list