From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ed1-f52.google.com (mail-ed1-f52.google.com [209.85.208.52]) (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 30F9E1F91F6 for ; Wed, 24 Jun 2026 13:15:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782306957; cv=none; b=UjQKJ4OxYhwBSfdl2TTy5ap6XZ4fH0La1nHTi21hgBqJmZMhXzgdCi7QFuAG9a+RMvwrG6FMkWd7g7PonJoIIIRbBIfjK3f/58ZpGgjvmS9CHB7r6fjAZRrX78eXrogmQ2iMHCEvQg0UIpz2GXN38SQBem9bAa/+AX6DVyJQgh0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782306957; c=relaxed/simple; bh=/nqB0qbAotm7Tm2k6JejyL6c3R4u9JfzmCNWpnZVIno=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=DwcBPc9ElEsDkBSbhj8s/YcnCBCQvYMZ72LcSHOQ1pi8Y17K0dLOD7Vm+j5RfrFMUSgbzuD5I+NY+eqRWEyh/21mKZ/qhobVtTP7tE21+zVL85STi551rLu3jBI8oRMDd35oMgPjsTaXZwJif7tVKuTcXdkBXXqORsInkrGGk/Q= 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=igRDAHUg; arc=none smtp.client-ip=209.85.208.52 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="igRDAHUg" Received: by mail-ed1-f52.google.com with SMTP id 4fb4d7f45d1cf-69690062350so1211823a12.0 for ; Wed, 24 Jun 2026 06:15:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1782306955; x=1782911755; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=N8zJXNAOj3TRSQqWHWqJVCbZ12C/VejTSJ/Qsl8Vpsg=; b=igRDAHUgYdSsbcEZaRHz/lszr/FDay4uqMsa+lrZw+BpH70CMnhrsFjJ20IvybXwK2 nwc1aNEtF2fgYZW7ceZVoXHntd6zGfI1h0WKeQvLR/HnpPMBllofsxRsTBI5k9Ealo29 hLEmYabCcInS3qngcMuPK9QtJsqYT0tx4NSIT7CKgcEoAJeUmPUemxTsvj6SVNemg9DU vlgvJ9jfhz/aPgOP7sWK41/z+7Yu23/xG67LA5qht6Gd9ZJoIgwQGM0wlWsZpKoIuXsN swQTyeJoOuKrGp3+HbjaIRlwM4K+9DnzR+yjmbNWm197GfMCcqFYJk+nKnyxOzKUujxi tCCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782306955; x=1782911755; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=N8zJXNAOj3TRSQqWHWqJVCbZ12C/VejTSJ/Qsl8Vpsg=; b=EU0IJP2X+qcl0hdDfItqkw6SwMeDckwYNo4GOdEG9D6OUwmmqSyVuz4Ua2clvGKnAd j9yS8GbjTMc6zHiAOnjwvlSFvcSKqDP3F2uHLsoscARRWLsjqV+aAaGrbJlAkWBIqOfN gjcRDHT/88NA6h+SfKK0j957GrogvjMX1na9FXoLTZGjZqbwNr4hM6OjLneO1vuZGaQo X5/mV2J2LWkruo0HtPo/CKzX+FK5hKScK+sWiAWUl4bFV61RFle+oA6M0jGGpGHhOzxM /KOzUs9vt+lU/PQ0pMypunFNplYqb0Ju5VLojE4oRmPUiP/wqIev/sFmIfGNUwA7rqSd lU2A== X-Forwarded-Encrypted: i=1; AHgh+Rrr5Mo2a2XjiBoTIMTcm/tE3lcJKIDmlQptNR5clsXhZAmm7BYmoixdzYIhiCQBxkhHKXzEf9aYPKhxMR4=@vger.kernel.org X-Gm-Message-State: AOJu0YzQ8lovxPmyuJk94feV8J+HE98AOhYBE2v3vYh6QB0HaCiMNZ2/ /e2OeKv3Y3c2TM4PpXG3xce++fCglHrpn+uEPStnNTPSNdop7vDIhYk1 X-Gm-Gg: AfdE7cmPx8wgXHtXJYFnjNk4cPt5cIYbl2EXzUdxQU7TdceBk7AJ6TuaQM0952+0iuE edJm4+PuHmQcOu0cXV/WBlKS1/9Czh7qKwTMg2wEM/M0wtKuX3a6Rrt5FzhmH0xZvOG8JIPucIH zN9RiVvQ/6VtS35oKEbZ+QRXM7c8NQMqYUdWVBXC0oHZT85Nk2pVjpA5G3UznJsUp4yrkh6fx3H HXi5goMXTpP3vG8s1TzNgTJqFAUTCzJnUB3oQkt5PrvggkZtWXCnZVZUq9hch9zItCVRB3ZGDNK qT0pxig3FCCj5QNgkCqrIvUys8/PGaMfSltQiNJYE47rhSIhExwXYs11MzWAEtD0tVR7mj+yxV3 eTAF/OBJI5swIQIuxx3uZDoZi7E33dAChQJZN8a1qTQrJ4UIfc6IR7oSsM3vHzoPiMaPzLJKIUv yW0vu7p9cn X-Received: by 2002:a05:6402:4591:b0:697:decc:7f9a with SMTP id 4fb4d7f45d1cf-697f387a521mr1657893a12.9.1782306954280; Wed, 24 Jun 2026 06:15:54 -0700 (PDT) Received: from localhost ([196.207.164.177]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-697f3ade18esm1152759a12.7.2026.06.24.06.15.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jun 2026 06:15:53 -0700 (PDT) Date: Wed, 24 Jun 2026 16:15:49 +0300 From: Dan Carpenter To: Geert Uytterhoeven Cc: Andrzej Pietrasiewicz , 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: Re: [PATCH v2] thermal/drivers/rcar: fix error checking in probe() Message-ID: References: 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 In-Reply-To: On Wed, Jun 24, 2026 at 03:12:47PM +0200, Geert Uytterhoeven wrote: > Hi Dan, > > On Wed, 24 Jun 2026 at 15:03, Dan Carpenter wrote: > > 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. > > Thanks for the update! > > Reviewed-by: Geert Uytterhoeven > > > --- a/drivers/thermal/renesas/rcar_thermal.c > > +++ b/drivers/thermal/renesas/rcar_thermal.c > > > @@ -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; > > This error path is the same in the other branch, so it could be shared > after the if/else block. > Even better. :) v3 coming up. regards, dan carpenter