From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dirk Behme Subject: Re: [PATCH] thermal: rcar_thermal: Fix priv->zone error handling Date: Tue, 3 May 2016 19:46:22 +0200 Message-ID: <5728E3EE.6030506@gmail.com> References: <1461234295-30521-1-git-send-email-dirk.behme@de.bosch.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: Sender: linux-renesas-soc-owner@vger.kernel.org To: Geert Uytterhoeven , Linux PM list , Zhang Rui , Eduardo Valentin Cc: Dirk Behme , linux-renesas-soc@vger.kernel.org, Kuninori Morimoto List-Id: linux-pm@vger.kernel.org On 21.04.2016 15:00, Geert Uytterhoeven wrote: > On Thu, Apr 21, 2016 at 12:24 PM, Dirk Behme wrote: >> In case thermal_zone_xxx_register() returns an error, priv->zone >> isn't NULL any more, but contains the error code. >> >> This is passed to thermal_zone_device_unregister(), then. This checks >> for priv->zone being NULL, but the error code is != NULL. So it works >> with the error code as a pointer. Crashing immediately. >> >> To fix this, reset priv->zone to NULL before entering >> rcar_gen3_thermal_remove(). > > Alternatively, you could prevent a non-valid zone pointer from ever > ending up in priv->zone by assigning the zone to a temporary variable, > and only storing that in priv->zone after the error check. > >> Signed-off-by: Dirk Behme > > Regardless of the above > Reviewed-by: Geert Uytterhoeven Could this be applied, then? Best regards Dirk