[PATCH] thermal/drivers/rcar: add error checking in probe()

From: Dan Carpenter

Date: Tue Jun 23 2026 - 03:50:31 EST


The thermal_zone_device_register_with_trips() can fail for a number of
reasons, including allocation failures. Check for error pointers to
avoid an error pointer dereference.

Fixes: 9d617949d490 ("thermal/drivers/renesas: Group all renesas thermal drivers together")
Signed-off-by: Dan Carpenter <error27@xxxxxxxxx>
---
drivers/thermal/renesas/rcar_thermal.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/drivers/thermal/renesas/rcar_thermal.c b/drivers/thermal/renesas/rcar_thermal.c
index 6e5dcac5d47a..71f836fbc698 100644
--- a/drivers/thermal/renesas/rcar_thermal.c
+++ b/drivers/thermal/renesas/rcar_thermal.c
@@ -492,6 +492,11 @@ static int rcar_thermal_probe(struct platform_device *pdev)
"rcar_thermal", trips, ARRAY_SIZE(trips), priv,
&rcar_thermal_zone_ops, NULL, 0,
idle);
+ if (IS_ERR(priv->zone)) {
+ ret = PTR_ERR(priv->zone);
+ priv->zone = NULL;
+ goto error_unregister;
+ }

ret = thermal_zone_device_enable(priv->zone);
if (ret) {
--
2.53.0