From patchwork Tue Aug 16 08:51:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 9282905 X-Patchwork-Delegate: rui.zhang@intel.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 52AC560839 for ; Tue, 16 Aug 2016 08:51:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 42836288A3 for ; Tue, 16 Aug 2016 08:51:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 36D47288AB; Tue, 16 Aug 2016 08:51:47 +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=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham 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 C96DD288A3 for ; Tue, 16 Aug 2016 08:51:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751532AbcHPIvo (ORCPT ); Tue, 16 Aug 2016 04:51:44 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:36236 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751269AbcHPIvn (ORCPT ); Tue, 16 Aug 2016 04:51:43 -0400 Received: by mail-wm0-f68.google.com with SMTP id i138so15130486wmf.3; Tue, 16 Aug 2016 01:51:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=E7ZClY1YJP2hLxex6GDoofloadxChHQuD8nV6Z7eN1Q=; b=Y7FZSBKOhdtwuTjmuetcnEeIgSetPY6ZJJp6+9SY/RnqWsiDZ+mCpA5RadYNHNzZlP KlhWsmcH42Al2CCsjZ39iG+t00hBARzSNxftymA7/yxGm/S/9gDittBq4kXwT4NcmkDJ 4aeOjf2epHYeDS55aru7dag8GtdRewuQe6r8FIkkLNBMKOubYJQZ4MT8PIMvFPzoqhHZ tyLoN9zx/yOSz2myWbCbXsNzxFY8T3ZGVrsEh2B3UKO5/qcqBeMPOn2+5RpKPe50eJox xcQQfHrV7evcFGn5CuU2HRE+85kMlYF5nBkDdN4Fh3zpOaXEaqsFybbWMTaXGy/X2Wz6 60eQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=E7ZClY1YJP2hLxex6GDoofloadxChHQuD8nV6Z7eN1Q=; b=KOT0dxSZlEHKHN8PJzwsVK5TRLeN47xupmTH/GRmRgPR4FRTiDYAjRBN0aaUc3azQQ Htwi9nbLJ5EFmZZmtY2Drc6GkbPc+fiTb4BytRZvfytrj4emNWb058/DCSlX/IHW9KVR h044umqvSwIhHqNFtDL3J0JKKwT0d/yHEB9fqim8vfcVcB3STzzume8eja68cKKJe3tz vPoLP7DJaJCw8F2WHPUNrIonzfZGGz2Kg6BdYm21S8nqxsTyc/tL8J/0pKxwthY5GRFL 87BRvgGSKgcudLsWnKg/HM5fD2UR2XqEPZqchIoOFAcV9KeLC30r12/fwws/QOJT2CGQ 65zQ== X-Gm-Message-State: AEkoouv/WgcuQOZ1qgHc1daSkkmANf4itlTiPY5fQzOYO1Z3EhQ1U7yKx8NLuHhQnkHrBg== X-Received: by 10.194.143.17 with SMTP id sa17mr34998495wjb.97.1471337501842; Tue, 16 Aug 2016 01:51:41 -0700 (PDT) Received: from Red.local (ANice-651-1-389-119.w86-205.abo.wanadoo.fr. [86.205.21.119]) by smtp.googlemail.com with ESMTPSA id i8sm20631024wmg.21.2016.08.16.01.51.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 16 Aug 2016 01:51:41 -0700 (PDT) From: LABBE Corentin To: rui.zhang@intel.com, edubezval@gmail.com Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, LABBE Corentin Subject: [PATCH] thermal: imx: fix a possible NULL dereference Date: Tue, 16 Aug 2016 10:51:38 +0200 Message-Id: <1471337498-6382-1-git-send-email-clabbe.montjoie@gmail.com> X-Mailer: git-send-email 2.7.3 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 of_match_device could return NULL, and so cause a NULL pointer dereference later at line 472: data->socdata = of_id->data; For fixing this problem, we use of_device_get_match_data(), this will simplify the code a little by using a standard function for getting the match data. Reported-by: coverity (CID 1324128) Signed-off-by: LABBE Corentin --- drivers/thermal/imx_thermal.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c index c5547bd..e473548b 100644 --- a/drivers/thermal/imx_thermal.c +++ b/drivers/thermal/imx_thermal.c @@ -471,8 +471,6 @@ MODULE_DEVICE_TABLE(of, of_imx_thermal_match); static int imx_thermal_probe(struct platform_device *pdev) { - const struct of_device_id *of_id = - of_match_device(of_imx_thermal_match, &pdev->dev); struct imx_thermal_data *data; struct regmap *map; int measure_freq; @@ -490,7 +488,7 @@ static int imx_thermal_probe(struct platform_device *pdev) } data->tempmon = map; - data->socdata = of_id->data; + data->socdata = of_device_get_match_data(&pdev->dev); /* make sure the IRQ flag is clear before enabling irq on i.MX6SX */ if (data->socdata->version == TEMPMON_IMX6SX) {