From patchwork Thu Apr 21 10:24:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dirk Behme X-Patchwork-Id: 8898691 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Original-To: patchwork-linux-renesas-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id BE1B0BF29F for ; Thu, 21 Apr 2016 10:26:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2E3AA202E5 for ; Thu, 21 Apr 2016 10:26:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 41AF6200CC for ; Thu, 21 Apr 2016 10:26:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751571AbcDUK0B (ORCPT ); Thu, 21 Apr 2016 06:26:01 -0400 Received: from smtp6-v.fe.bosch.de ([139.15.237.11]:44077 "EHLO smtp6-v.fe.bosch.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751531AbcDUK0A (ORCPT ); Thu, 21 Apr 2016 06:26:00 -0400 Received: from vsmta14.fe.internet.bosch.com (unknown [10.4.98.54]) by imta23.fe.bosch.de (Postfix) with ESMTP id 7CE4015801AC; Thu, 21 Apr 2016 12:25:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=de.bosch.com; s=2015-01-21; t=1461234358; bh=dR0OCFMQPsXNo97crEg1yUxuzoykpIY59HiIsBMOCy4=; l=10; h=From:From:Reply-To:Sender; b=vYDpLzjZTGJE8lmN8Zwr9pDrzng35CG/6RkA+hd94u8BM3I6j56i/JCfVn+iPd5H+ PIr+0K5DJCiURH/bu6BpH8lpsewu84nbJwsCmN3We+6EZe6pmS5pmKvbiuhT4KR8Gi xb4etgAFLun0OYXv6DKJzb6VVOaHUAQ8CKQVnFWI= Received: from FE-HUB1000.de.bosch.com (vsgw24.fe.internet.bosch.com [10.4.98.24]) by vsmta14.fe.internet.bosch.com (Postfix) with ESMTP id 423C4A40274; Thu, 21 Apr 2016 12:25:58 +0200 (CEST) Received: from hi-z08if.hi.de.bosch.com (10.34.209.31) by FE-HUB1000.de.bosch.com (10.4.103.107) with Microsoft SMTP Server id 14.3.195.1; Thu, 21 Apr 2016 12:25:57 +0200 Received: from hi-z08if.hi.de.bosch.com (localhost [127.0.0.1]) by hi-z08if.hi.de.bosch.com (Postfix) with ESMTP id 0223C625E61; Thu, 21 Apr 2016 12:24:57 +0200 (CEST) From: Dirk Behme To: , , , , CC: Dirk Behme Subject: [PATCH] thermal: rcar_thermal: Fix priv->zone error handling Date: Thu, 21 Apr 2016 12:24:55 +0200 Message-ID: <1461234295-30521-1-git-send-email-dirk.behme@de.bosch.com> X-Mailer: git-send-email 2.8.0 MIME-Version: 1.0 X-TM-AS-MML: disable X-TM-AS-Product-Ver: IMSS-7.1.0.1679-8.0.0.1202-22272.006 X-TMASE-MatchedRID: 6oQ587FGqXtNX7KC6L8DnsnUT+eskUQPgGa+oYp5i6pNShtWKzkFvzCH Bv5Fitn/cODoO2WaU5UOiVgo5BJRrYrFHTmMFhb3EhGH3CRdKUUpxoenBUOrId9RlPzeVuQQfdQ 7p2bSGhbi8zVgXoAltsYlDcGKIsCCC24oEZ6SpSlsZUSYh+N/e5l3b1F4tdu7X5qaOmth8wnO7z KsF5YXXZN+qSSBUjo6DuQDrFNfJbQ= Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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(). Signed-off-by: Dirk Behme Reviewed-by: Geert Uytterhoeven --- drivers/thermal/rcar_thermal.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c index 71a3392..5f81792 100644 --- a/drivers/thermal/rcar_thermal.c +++ b/drivers/thermal/rcar_thermal.c @@ -504,6 +504,7 @@ static int rcar_thermal_probe(struct platform_device *pdev) if (IS_ERR(priv->zone)) { dev_err(dev, "can't register thermal zone\n"); ret = PTR_ERR(priv->zone); + priv->zone = NULL; goto error_unregister; }