From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ed1-f50.google.com (mail-ed1-f50.google.com [209.85.208.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 615B52641CA for ; Wed, 24 Jun 2026 13:03:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782306198; cv=none; b=O7siVN7COCypQ7BYLGOkHe2Zpgp8JJreJLUhozEHspaR7yDPtoIXSac0V5uKocekVM0PT/Lga/DUfnygpDvJWkTsqQmHKhD1xtJ5EVCwp8S7KNYczcDWARn+PRel9ZKAHS9RBaS43Bz9oLomCgPtip5ZCuBu8Nu4/E4/0K01oYc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782306198; c=relaxed/simple; bh=4wmUG9+jETW1+KM0ZXFsMsDz7lw3gBvAJtfCC3yXuug=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=GkeSX7XCzBQ1OICl5i+vbuEna1HJj+AEGq6T8LsWoJFyyHI2GfwSL8WTfAPnvi+Epg7gQlW2Tsb5S7PjTRLPMsZtI7H0FT+gLorw829DW+fL+6UICC60Zv20E+lhwzCHxVGXdisA4kR10GlxI+TNVh4CoHcaEPZjLlZSfH9z8Vo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=TPenzY8G; arc=none smtp.client-ip=209.85.208.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="TPenzY8G" Received: by mail-ed1-f50.google.com with SMTP id 4fb4d7f45d1cf-697ce8cfe65so1644766a12.3 for ; Wed, 24 Jun 2026 06:03:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1782306194; x=1782910994; darn=vger.kernel.org; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=IqbffuHROsrMfivcmxl/a0WRNEEypXicIfc5X1ORIW4=; b=TPenzY8G603F2SfksgutFmXYP8R0NY6G/BLUwo5OsLTTpwrkAnUD5pFaGsGcH5cy6p kh2lanK3JMuqDY5qK8Lg9K/Iccff7GNX2kKqGMC8onUe0KR3yrv+S506z0eur199+9ZN tU4xcJXuQVakabMkXAEd9F30kAZ7QsXBojikXUi+aFQSdqlfjoVCygPbk/sKXNPCoaOU fgKbS/BUbOs0itTRvXBnPIlaNkWQUB5Gp2KPb6fzKtX522bzT2mzd5a80BOmhiHQ3asO KlYgLtjN8QUeAEqYuFjWu+rSbhoE4sqJxkx3uxYeLZmNJyx0eeFBLLbZSSbRxigQXLPf sW3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782306194; x=1782910994; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=IqbffuHROsrMfivcmxl/a0WRNEEypXicIfc5X1ORIW4=; b=azs5CWiWQh2hna7psxow42sSsNDh+qZIjPB8LfA3LgOKts46Nu2WXcB+BhLQe2MY4E bjc/nDaQJ4WfL3uiRI6WnSOF1u4fjgan665H0k/xOlRM1Y4pm2AcWDDabsKyygCCImDH X1tD+/7D+valvRqnFZrrFzKZUAK9FDWjEU/sSqwwFk/my2G1CFRamYKVpAQJXgviJIzS CCkJS33W8wRLEU/wDBBXl19TpVSbzEwvgeBn5zvQ+K+kVo/gxLbngSqqb9HJHICZrE7J qzt8dME01v4/VWEjcx72GUIzI7lmDHNZmRe3QpksxBkwJU3Na0AUcXpAvhdVSFXkKi1w NQtQ== X-Forwarded-Encrypted: i=1; AFNElJ9bzNcTgHsWUSyF0DfGanZPcm6Qn/tAPW6l13OgtxBDTxf5Lz5oJejNzHOQdNiLuW88RLjb0Kpbj+78lms=@vger.kernel.org X-Gm-Message-State: AOJu0Yyje68UhOdTPaE790pfLTpgp9t5JGdZh0mPmKzNpMs52ZHFWwjK CHKnZ5LtwPZJ7QmY8gSHBngB6fFK+4/sDikz6b0fBe4uSTSLyFoYA+GF X-Gm-Gg: AfdE7cmTWU9DkxKCobQuy/l6i6HdHhG22Cd7dLCY5jL2C0L3x/Z9BWcfp9gV4mMtfoP BNzFrLfZ7A2I1nsDLZWQnrPV1DpfHZfg3yGsJn/WQbIftYVYiyC3GTrb23fLtt7UfdVmrZpdgTV ITcpEq2kYWC6FL65niltbSkjGgX23rlJ8uv/mXRsFsn6hrwz0LOscrAoh1pNYyWU3wdomZ1w2BG 6fDu+06TcytJSBbgZOvwVx3rnG9DZwI14NuxLJX5/GM50WcncLSvtDmfe4xYhHOmq1akf1yW9Py 9zbY41NgiS2uJZU3q56wBjfsG7fWoahV7lwpB9+XfQ0rv3OEDXgTtjfpn9DxavGjg7CRbMpTSUg LfG0D3EIsJAqP6AmARq8DE2BzGZdDJfXhh+gOCxSXE1Ake6NCAjO74TARsstb6hrtNrJgHuTGOP SrW/Q+m+rR X-Received: by 2002:a17:906:2081:b0:c11:f023:8414 with SMTP id a640c23a62f3a-c11f0238ac8mr89463366b.22.1782306193376; Wed, 24 Jun 2026 06:03:13 -0700 (PDT) Received: from localhost ([196.207.164.177]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c0c5e497e7dsm651298766b.5.2026.06.24.06.03.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jun 2026 06:03:12 -0700 (PDT) Date: Wed, 24 Jun 2026 16:02:53 +0300 From: Dan Carpenter To: Andrzej Pietrasiewicz Cc: Niklas =?iso-8859-1?Q?S=F6derlund?= , "Rafael J. Wysocki" , Daniel Lezcano , Zhang Rui , Lukasz Luba , Geert Uytterhoeven , Magnus Damm , Bartlomiej Zolnierkiewicz , linux-renesas-soc@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH v2] thermal/drivers/rcar: fix error checking in probe() Message-ID: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Mailer: git-send-email haha only kidding 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. 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") Signed-off-by: Dan Carpenter --- v2: Use the correct fixes tag and re-write the check in a cleaner way. drivers/thermal/renesas/rcar_thermal.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/thermal/renesas/rcar_thermal.c b/drivers/thermal/renesas/rcar_thermal.c index 6e5dcac5d47a..f8865b03ed23 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"); @@ -510,6 +504,10 @@ static int rcar_thermal_probe(struct platform_device *pdev) 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