]> git.baikalelectronics.ru Git - kernel.git/commit
of: properly check for error returned by fdt_get_name()
authorFrank Rowand <frank.rowand@sony.com>
Mon, 5 Apr 2021 03:28:45 +0000 (22:28 -0500)
committerRob Herring <robh@kernel.org>
Wed, 7 Apr 2021 18:07:30 +0000 (13:07 -0500)
commit087b5dff2634120d6f4841d5f9673780d252b412
tree039e9f4c1c4242a9ff56dc105a42a31570a225bc
parent96d33eea760437c793421dfc080180e25952e301
of: properly check for error returned by fdt_get_name()

fdt_get_name() returns error values via a parameter pointer
instead of in function return.  Fix check for this error value
in populate_node() and callers of populate_node().

Chasing up the caller tree showed callers of various functions
failing to initialize the value of pointer parameters that
can return error values.  Initialize those values to NULL.

The bug was introduced by
commit 37b8da12b27c ("of/fdt: Convert FDT functions to use libfdt")
but this patch can not be backported directly to that commit
because the relevant code has further been restructured by
commit dfdc4dbf8016 ("drivers/of: Split unflatten_dt_node()")

The bug became visible by triggering a crash on openrisc with:
commit 2b9136faec55 ("scripts/dtc: Update to upstream version v1.6.0-51-g183df9e9c2b9")
as reported in:
https://lore.kernel.org/lkml/20210327224116.69309-1-linux@roeck-us.net/

Fixes: 2b9136faec55 ("scripts/dtc: Update to upstream version v1.6.0-51-g183df9e9c2b9")
Reported-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Frank Rowand <frank.rowand@sony.com>
Tested-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20210405032845.1942533-1-frowand.list@gmail.com
Signed-off-by: Rob Herring <robh@kernel.org>
drivers/of/fdt.c
drivers/of/overlay.c
drivers/of/unittest.c