thermal/of: Fix error code in of_thermal_zone_find()
authorDan Carpenter <dan.carpenter@oracle.com>
Tue, 9 Aug 2022 08:56:26 +0000 (10:56 +0200)
committerDaniel Lezcano <daniel.lezcano@linaro.org>
Wed, 17 Aug 2022 12:09:37 +0000 (14:09 +0200)
Currently, if we cannot find the correct thermal zone then this error
path returns NULL and it would lead to an Oops in the caller.  Return
ERR_PTR(-EINVAL) instead.

Fixes: 3bd52ac87347 ("thermal/of: Rework the thermal device tree initialization")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/YvDzovkMCQecPDjz@kili
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
drivers/thermal/thermal_of.c

index 82236fec7c65415f7ab937ccd6f09b7112f0139e..15b342fa81d6dbcb220a7ba5deb096159c9c1256 100644 (file)
@@ -1102,6 +1102,7 @@ static struct device_node *of_thermal_zone_find(struct device_node *sensor, int
                        }
                }
        }
+       tz = ERR_PTR(-EINVAL);
 out:
        of_node_put(np);
        return tz;