From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from fhigh-b1-smtp.messagingengine.com (fhigh-b1-smtp.messagingengine.com [202.12.124.152]) (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 66A882848BE; Tue, 23 Jun 2026 08:18:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.152 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782202709; cv=none; b=Phr97v4TkaLqspv70Vv7ZqAd9uD8VtlsrZ+vXgsB6t5AUEPSCDtussLHf5PKFvHpkuxsuNcCNhjwQTz/g+SyoFQvcy5/MPy824hhpfqKp8AMl/rFPJAdszVIzp0dVIqhvTcqBkoGNNjxeLgRcct4WSQDZZofTEFCWMctloyc8zg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782202709; c=relaxed/simple; bh=yoUzsa95RhqJEgutS52suqvIBpvD7HV/GdWxjcvRMKI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=n1RKi1N3+0Ruiu8dPaRzaF0gmw4UjRQSNUw8skA6JXr5cggi2j1c5hExdpSJ8UhLrUtuMUMKf2fjl+1k41fZOlRL8+/EdIstYQMaO0vBWKnqnsKrohueg0rKSWDrnzpVO6MmmCSMCebxPDdJ0htpir/3Kr5riOYVLEECdUPRSlI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ragnatech.se; spf=pass smtp.mailfrom=ragnatech.se; dkim=pass (2048-bit key) header.d=ragnatech.se header.i=@ragnatech.se header.b=D8iiQu1z; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=KBDWkrso; arc=none smtp.client-ip=202.12.124.152 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ragnatech.se Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ragnatech.se Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ragnatech.se header.i=@ragnatech.se header.b="D8iiQu1z"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="KBDWkrso" Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfhigh.stl.internal (Postfix) with ESMTP id 624237A013C; Tue, 23 Jun 2026 04:18:26 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-05.internal (MEProxy); Tue, 23 Jun 2026 04:18:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ragnatech.se; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1782202706; x=1782289106; bh=uZgbKFGXZqJi9f6tN/Bf7E+BgXfTbBHtxrri4BcfqOI=; b= D8iiQu1zxw5G7Tg5NnHwhmQVBhsF0BBbbW1WdXyoCblqbE3p8+ZUvEHkpox8pcgn 1OapQBR1cEpTs8rUP8fVjE0uqfO/isdHTKmdOgaumebRgren8G5BP2y2zEAuvzMv B3wBPV1dMAcVtMretflxXI5jP5+ejfxZa96qPUxXLv+BFA8ysPaBtaTScYWOETfy g6ZYcQhKA5NjOCQa/imW7LzFbqiC7udppObf446GR/7BBbv53Y1D6heNJz2sQKOn ly8kC+0YhSfZfPaC5UTIgcUp4Pkhv2XdEl9/qAB08c8d0LNJVVQ2f9v8ub0rTGFT N0mppnG8dIP1bylpnYa0Kg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=f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OCJHhnGt dNA1dIMBKmdVTazgigOenrdOqt0OG/6hfkMfcM9PLKeIufZ71noSf1d2OCnQ X-ME-Proxy: Feedback-ID: i80c9496c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 23 Jun 2026 04:18:25 -0400 (EDT) Date: Tue, 23 Jun 2026 10:18:22 +0200 From: Niklas =?utf-8?Q?S=C3=B6derlund?= To: Dan Carpenter Cc: "Rafael J. Wysocki" , Daniel Lezcano , Zhang Rui , Lukasz Luba , Geert Uytterhoeven , Magnus Damm , linux-renesas-soc@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: Re: [PATCH] thermal/drivers/rcar: add error checking in probe() Message-ID: <20260623081822.GB3937090@ragnatech.se> References: Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Hi Dan, Thanks for your work. On 2026-06-23 10:49:29 +0300, Dan Carpenter wrote: > 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") I don't think this is correct as this commits just moves the file. > Signed-off-by: Dan Carpenter > --- > 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; > + } While this indeed is an issue that should be fixed I don't think this is the correct fix. Below the if .. else .. block where this is added there already is a check for IS_ERR(priv->zone). That however does not guard against the usage of priv->zone for thermal_zone_device_enable(). We should only call thermal_zone_device_enable() if we are on a system that uses OF (gated by chip->use_of_thermal) which is the reason for the if .. else .. block in the first place. As chance have it we also have a check on chip->use_of_thermal directly after the existing IS_ERR(priv->zone) check. I think it would be better to move the call to thermal_zone_device_enable() there and avoid having two checks for IS_ERR(priv->zone)? Something like this, diff --git a/drivers/thermal/renesas/rcar_thermal.c b/drivers/thermal/renesas/rcar_thermal.c index 6e5dcac5d47a..dd13cf971ddb 100644 --- a/drivers/thermal/renesas/rcar_thermal.c +++ b/drivers/thermal/renesas/rcar_thermal.c @@ -492,12 +492,6 @@ static int rcar_thermal_probe(struct platform_device *pdev) "rcar_thermal", trips, ARRAY_SIZE(trips), 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"); @@ -507,13 +501,16 @@ static int rcar_thermal_probe(struct platform_device *pdev) } if (chip->use_of_thermal) { + ret = thermal_zone_device_enable(priv->zone); + if (ret) + goto error_of_thermal; + ret = thermal_add_hwmon_sysfs(priv->zone); if (ret) - goto error_unregister; + goto error_of_thermal; } rcar_thermal_irq_enable(priv); - list_move_tail(&priv->list, &common->head); /* update ENR bits */ @@ -528,6 +525,8 @@ static int rcar_thermal_probe(struct platform_device *pdev) return 0; +error_of_thermal: + thermal_zone_device_unregister(priv->zone); error_unregister: rcar_thermal_remove(pdev); > > ret = thermal_zone_device_enable(priv->zone); > if (ret) { > -- > 2.53.0 > -- Kind Regards, Niklas Söderlund