From patchwork Tue Jul 24 11:14:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 10541855 X-Patchwork-Delegate: eduardo.valentin@ti.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ED5CE112B for ; Tue, 24 Jul 2018 11:14:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DD3D7285EE for ; Tue, 24 Jul 2018 11:14:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D12C22877B; Tue, 24 Jul 2018 11:14:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 79CFD28701 for ; Tue, 24 Jul 2018 11:14:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388447AbeGXMUS (ORCPT ); Tue, 24 Jul 2018 08:20:18 -0400 Received: from kirsty.vergenet.net ([202.4.237.240]:44782 "EHLO kirsty.vergenet.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388241AbeGXMUR (ORCPT ); Tue, 24 Jul 2018 08:20:17 -0400 Received: from reginn.horms.nl (watermunt.horms.nl [80.127.179.77]) by kirsty.vergenet.net (Postfix) with ESMTPA id 3238425B81D; Tue, 24 Jul 2018 21:14:19 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=verge.net.au; s=mail; t=1532430859; bh=V+2Q789/uPU+fpHKdTzdHgm6diF/PgnWL3HcbO0HmWY=; h=From:To:Cc:Subject:Date:From; b=Grd1qRl/9fpvH/vTz+3mYj3out9/8svzR5pxQrEMbZp33n0hsblv7vGsbhxd7GajP ndTPOiwo9Rt5Xp6vywpWe7AyTHCQ94dWugeRg+bx3La6OhGoeUfEF2Tr+0Y3rbepbd AVwg7EszrOwmZH1I9gcQ8ud7vDPZyEmwDdV3qUaU= Received: by reginn.horms.nl (Postfix, from userid 7100) id 17858940388; Tue, 24 Jul 2018 13:14:17 +0200 (CEST) From: Simon Horman To: Zhang Rui , Eduardo Valentin Cc: Yoshihiro Kaneko , Magnus Damm , linux-pm@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Simon Horman Subject: [PATCH] thermal: rcar_thermal: avoid NULL dereference in absense of IRQ resources Date: Tue, 24 Jul 2018 13:14:13 +0200 Message-Id: <20180724111413.4056-1-horms+renesas@verge.net.au> X-Mailer: git-send-email 2.11.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Ensure that the base address used by a call to rcar_thermal_common_write() may be NULL if the SOC supports interrupts for use with the thermal device but none are defined in DT as is the case for R-Car H1 (r8a7779). Guard against this condition to prevent a NULL dereference when the device is probed. Tested on: * R-Mobile APE6 (r8a73a4) / APE6EVM * R-Car H1 (r8a7779) / Marzen * R-Car H2 (r8a7790) / Lager * R-Car M2-W (r8a7791) / Koelsch * R-Car M2-N (r8a7793) / Gose * R-Car D3 ES1.0 (r8a77995) / Draak Fixes: 1969d9dc2079 ("thermal: rcar_thermal: add r8a77995 support") Signed-off-by: Simon Horman Reviewed-by: Geert Uytterhoeven --- Based on v4.18-rc6 --- drivers/thermal/rcar_thermal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c index 45fb284d4c11..e77e63070e99 100644 --- a/drivers/thermal/rcar_thermal.c +++ b/drivers/thermal/rcar_thermal.c @@ -598,7 +598,7 @@ static int rcar_thermal_probe(struct platform_device *pdev) enr_bits |= 3 << (i * 8); } - if (enr_bits) + if (common->base && enr_bits) rcar_thermal_common_write(common, ENR, enr_bits); dev_info(dev, "%d sensor probed\n", i);