From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4B2B72F8E86; Sat, 12 Sep 2026 16:11:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789229493; cv=none; b=tMFy2ngN7YtDVcLcZzImjk70bYZ1EHVe3TE2OPH+PANZ5z3RnXGX1BYxJtAG9yP4HZ3sAMt00RB3xqXeE2QZPY+ON47xJbKPPwL3RgKOisexWdLfZXs2RtwEGgmg1llOkh8O/A/NbQxehpetAbrr0wOACC+RYmf0cOTa9ujwjdA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789229493; c=relaxed/simple; bh=ne2QxB73CW0vc66t0/H2B8GCH4Pj8V1Rp0RoADlCVik=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=G2YrgIV5NIzjgnUxADBAXFTKYszzsppp7yg3OUshFhM7T+WhEuqjEWDIUCLR3UgSk3H05JGC2mGU8asq9rjmz8Tb2h0XPa5lkJHPVNWfjTPLZjgMIgrgQpQSSx87Kj0Ezzj+Jdn2iRUAKkc1KIjnqO5E4Rl4pt8x170Fm3FaXSo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=0PFCRtLC; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="0PFCRtLC" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E65AA1F000FF; Sat, 12 Sep 2026 16:11:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789229492; bh=u8vVDtGxnjyyCRmD/AZYQmVs2tks9YFe85C09SZGyOE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=0PFCRtLCSTyQr3j6m3f5fuIpu5uPJAlGsfFFxCcJqS05V+jzXBuFAx0Rt5N8svdrd wmrKAcZTKOTg4Qu5CkaaXtZq+kaXOqcjmqNyai3TfXBoSPkk/OZqnuc/2AeWbtbNhW dRTMKk1skVgLvKg3lGBBmAlCQIApbI+TEv4iWGqE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Geert Uytterhoeven , =?UTF-8?q?Niklas=20S=C3=B6derlund?= , Dan Carpenter , Daniel Lezcano , Sasha Levin Subject: [PATCH 6.1 0559/1191] thermal/drivers/rcar: Fix error checking in probe() Date: Sat, 12 Sep 2026 08:54:47 +0200 Message-ID: <20260912065600.800008957@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260912065548.086904252@linuxfoundation.org> References: <20260912065548.086904252@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Dan Carpenter [ Upstream commit dd04ad1cdabcad51e34b74b4e91b9aeb7180d05d ] This code accidentally calls thermal_zone_device_enable() before checking whether thermal_zone_device_register_with_trips() failed. Move the call until later to avoid an error pointer dereference of "priv->zone". The driver works differently depending on if we are using OF thermal or not. We use thermal_add_hwmon_sysfs() if we are using OF thermal and call thermal_zone_device_enable() if not. We can share same error check for if either of these fail. Moving the thermal_zone_device_enable() call is a bit cleaner as well. The original code used a three step process to cleanup: 1. Call thermal_zone_device_unregister() to cleanup. 2. Set priv->zone to an error pointer to preserve the error code. 3. Set priv->zone to NULL to avoid a second call to thermal_zone_device_unregister() in the rcar_thermal_remove() function. Now we can just do a direct goto error_unregister and rcar_thermal_remove() handles the cleanup properly. Fixes: bbcf90c0646a ("thermal: Explicitly enable non-changing thermal zone devices") Reviewed-by: Geert Uytterhoeven Reviewed-by: Niklas Söderlund Signed-off-by: Dan Carpenter Signed-off-by: Daniel Lezcano Link: https://patch.msgid.link/aj5WnseULiwgmlWv@stanley.mountain Signed-off-by: Sasha Levin --- drivers/thermal/rcar_thermal.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c index 740250adc3d28..4871027013344 100644 --- a/drivers/thermal/rcar_thermal.c +++ b/drivers/thermal/rcar_thermal.c @@ -536,12 +536,6 @@ static int rcar_thermal_probe(struct platform_device *pdev) 1, 0, priv, &rcar_thermal_zone_ops, NULL, 0, idle); - - ret = thermal_zone_device_enable(priv->zone); - if (ret) { - thermal_zone_device_unregister(priv->zone); - priv->zone = ERR_PTR(ret); - } } if (IS_ERR(priv->zone)) { dev_err(dev, "can't register thermal zone\n"); @@ -550,11 +544,12 @@ static int rcar_thermal_probe(struct platform_device *pdev) goto error_unregister; } - if (chip->use_of_thermal) { + if (chip->use_of_thermal) ret = thermal_add_hwmon_sysfs(priv->zone); - if (ret) - goto error_unregister; - } + else + ret = thermal_zone_device_enable(priv->zone); + if (ret) + goto error_unregister; rcar_thermal_irq_enable(priv); -- 2.53.0