From patchwork Sat Feb 20 22:23:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin King X-Patchwork-Id: 8367961 Return-Path: X-Original-To: patchwork-linux-pm@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 5A416C0553 for ; Sat, 20 Feb 2016 22:23:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8F60D2047C for ; Sat, 20 Feb 2016 22:23:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 88CC420461 for ; Sat, 20 Feb 2016 22:23:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759593AbcBTWXa (ORCPT ); Sat, 20 Feb 2016 17:23:30 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:37762 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753119AbcBTWX3 (ORCPT ); Sat, 20 Feb 2016 17:23:29 -0500 Received: from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1aXFvz-0004xe-9d; Sat, 20 Feb 2016 22:23:27 +0000 From: Colin King To: Zhang Rui , Eduardo Valentin , linux-pm@vger.kernel.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH] thermal: rcar: check for NULL return of of_match_device Date: Sat, 20 Feb 2016 22:23:27 +0000 Message-Id: <1456007007-11200-1-git-send-email-colin.king@canonical.com> X-Mailer: git-send-email 2.7.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, 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 From: Colin Ian King of_match_device can potentially return NULL, so we need to check for this case to avoid a null pointer dereference on of_id Signed-off-by: Colin Ian King --- drivers/thermal/rcar_thermal.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c index 0e735ac..5943881 100644 --- a/drivers/thermal/rcar_thermal.c +++ b/drivers/thermal/rcar_thermal.c @@ -431,13 +431,17 @@ static int rcar_thermal_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; struct resource *res, *irq; const struct of_device_id *of_id = of_match_device(rcar_thermal_dt_ids, dev); - unsigned long of_data = (unsigned long)of_id->data; + unsigned long of_data; int mres = 0; int i; int ret = -ENODEV; int idle = IDLE_INTERVAL; u32 enr_bits = 0; + if (!of_id) + return ret; + of_data = (unsigned long)of_id->data; + common = devm_kzalloc(dev, sizeof(*common), GFP_KERNEL); if (!common) return -ENOMEM;