VIM3 Ubuntu Kernel support CONFIG_OF_OVERLAY

hi

  1. i build the kernel khadas-vims-4.9.y and hope to support device tree CONFIG_OF_OVERLAY at kernel, so i edit .config file and add this line:

    CONFIG_OF_OVERLAY=y

  2. rebuild kernel source code and copy arch/arm64/boot/Image to /boot/zImage

  3. reboot the Ubuntu system, but it was crashed at kernel step, here is all boot message log: khadas_vim3_overlay_crash.txt

  4. key Information dump stack

    [ 12.303140@4] Call trace:
    [ 12.303145@4] [ffffff8020003850+ 112][] dump_backtrace+0x0/0x248
    [ 12.303148@4] [ffffff80200038c0+ 32][] show_stack+0x24/0x30
    [ 12.303152@4] [ffffff80200038e0+ 48][] dump_stack+0xa0/0xcc
    [ 12.303155@4] [ffffff8020003910+ 64][] ___might_sleep+0x108/0x160
    [ 12.303157@4] [ffffff8020003950+ 48][] __might_sleep+0x58/0x90
    [ 12.303160@4] [ffffff8020003980+ 32][] mutex_lock+0x2c/0x78
    [ 12.303163@4] [ffffff8020008dfbcc>] of_node_put+0x24/0x30
    [ 12.303173@4] [ffffff8020003a60+ 48][] of_get_next_available_child+0x70/0xa0
    [ 12.303177@4] [ffffff8020003a90+ 208][] meson_set_min_status+0xf8/0x1c0
    [ 12.303179@4] [ffffff8020003b60+ 80][] meson_cooldev_min_update+0xf4/0x208
    [ 12.303181@4] [ffffff8020003bb0+ 144][] meson_cooldev_probe+0x37c/0x568
    [ 12.303184@4] [ffffff8020003c40+ 48][] platform_drv_probe+0x60/0xc0
    [ 12.303185@4] [ffffff8020003c70+ 64][<ffffff8 bus_add_driver+0x1c4/0x230
    [ 12.303194@4] [ffffff8020003d80+ 32][] driver_register+0x6c/0x110
    [ 12.303196@4] [ffffff8020003da0+ 32][] __platform_driver_register+0x54/0x60
    [ 12.303200@4] [ffffff8020003dc0+ 16][] meson_cooldev_platdrv_init+0x18/0x20
    [ 12.303202@4] [ffffff8020003dd0+ 112][] do_one_initcall+0x44/0x138
    [ 12.303205@4] [ffffff8020003e40+ 96][] kernel_init_freeable+0x1a4/0x248
    [ 12.303207@4] [ffffff8020003ea0+ 0][] kernel_init+0x18/0x108
    [ 12.303209@4] [0000000000000000+ 0][] ret_from_fork+0x10/0x40
    [ 12.303231@4] OF: ERROR: Bad of_node_put() on /thermal-zones/ddr_thermal
    [ 12.303233@4] CPU: 4 0xa0/0xcc
    [ 12.303242@4] [ffffff80200039e0+ 48][] of_node_release+0xbc/0xc0
    [ 12.303244@4] [ffffff8020003a10+ 48][] kobject_put+0x84/0xe8
    [ 12.303246@4] [ffffff8020003a40+ 32][] of_node_put+0x24/0x30
    [ 12.303248@4] [ffffff8020003a60+ 48][] of_get_next_available_child+0x70/0xa0
    [ 12.303250@4] [ 64][] driver_probe_device+0x154/0x2b0
    [ 12.303258@4] [ffffff8020003cb0+ 48][] __driver_attach+0xc8/0xd0
    [ 12.303260@4] [ffffff8020003ce0+ 64][] bus_for_each_dev+0x5c/0xa8
    [ 12.303262@4] [ffffff8020003d20+ 32][] driver_attach+0x30/0x40
    [ 12.303263@4] [ffffff8020003d40+ 64][] bus_add_driver+0x1c4/0x230
    [ 12.303265@4] [ffffff8020003d80+ 32][] driver_register+0x6c/0x110
    [ 12.303266@4[ffffff8020003ea0+ 0][] kernel_init+0x18/0x108
    [ 12.303275@4] [0000000000000000+ 0][] ret_from_fork+0x10/0x40
    [ 12.303305@4] find tzd id: 0

hi:

i try to analyze the code and found a way make the kernel run pass. but still have dump info at boot time. the important thing is kernel run pass. i hope this issue can be fixed in future.

diff --git a/drivers/amlogic/thermal/meson_cooldev.c b/drivers/amlogic/thermal/meson_cooldev.c
index db2c9e47..91713461 100644
--- a/drivers/amlogic/thermal/meson_cooldev.c
+++ b/drivers/amlogic/thermal/meson_cooldev.c
@@ -129,6 +129,9 @@ static int meson_set_min_status(struct thermal_cooling_device *cdev,
                goto end;
        for_each_available_child_of_node(tzdnp, child) {
                coolmap = of_find_node_by_name(child, "cooling-maps");
+               if (!coolmap)
+                       goto end;
+
                for_each_available_child_of_node(coolmap, gchild) {
                        struct of_phandle_args cooling_spec;
                        int ret;