From patchwork Thu Aug 31 23:52:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolin Chen X-Patchwork-Id: 9933167 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 417B160362 for ; Thu, 31 Aug 2017 23:52:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 36CFE26E3A for ; Thu, 31 Aug 2017 23:52:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2BCF526E51; Thu, 31 Aug 2017 23:52:30 +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.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI 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 CFAB526E3A for ; Thu, 31 Aug 2017 23:52:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751618AbdHaXwP (ORCPT ); Thu, 31 Aug 2017 19:52:15 -0400 Received: from mail-pg0-f67.google.com ([74.125.83.67]:35636 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751307AbdHaXwM (ORCPT ); Thu, 31 Aug 2017 19:52:12 -0400 Received: by mail-pg0-f67.google.com with SMTP id r133so683612pgr.2; Thu, 31 Aug 2017 16:52:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=23R2Yv9L3fMcREVQh9++7GnKelUv94JdPgfMYrt+mYI=; b=TR68eTKA/7rNy68HWD3AQ/lOxN9VV2blkxzcEgEGd/DhSqKI8zkSkNeUrIidGrMPuV hNNVWqYQgtj/Tmpi2zFMKNxc9WRbPn/oEuDXbfdnkI/EiIiUNVOTm9Xeg90DmKdWVtTf EODxIqSy32SH5nKgScZwq2reiPDRKirkYu+NEwGhlK2tTh7M4w7MbRStR+btkdsSUeEk c7yxdRz23nh6Uvd6VF8xnhY3rXXO4N7chaAZWQRaMoEzf7KDGTfQIvsxLZZ4WHsFCI60 YBxeBThAwxmgDc3kLpuaCqASQfizYlVRWOxTlobXKgwm9sYSKR4HOHUY8hq0bPbsCfpQ I9RA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=23R2Yv9L3fMcREVQh9++7GnKelUv94JdPgfMYrt+mYI=; b=HIDKJl8uujTfeFuTCj6DJcOUkYVCHtBGTjHuNv0uDnhN/sHhHuJi0dkaL39ddcZ6cx HxsL4tacrhrKWl/bN8SRpXiLcd5p1VylO6WOhnb8OQtpthtQ/Dhr1xQ+nC0fTxgC6hlP ycTm+j6h81js2IZPHEDBzWlN6ilisObDUdAVa7J2OFdgMI2MFTT908rS/1vkoGLeBPQV HMEy1Up3xH3Nz3cyYRrOWjqVtIDhjcLl0NgwOjhE4Adb7aaSIrfDOoox5e+w2Cy0sNCh QiqymWud0j9ajuvJTitH9uipjoL4p+eqclNfkgb9kkw5e6CVZiz2KajjeuHq6UeRNk2y hSaw== X-Gm-Message-State: AHPjjUhx99E0QumF/p5a94VPaYs/GY0TzxCUFCDByZhoPhV0MdQsWN1B jUaD087hzXn7aw== X-Google-Smtp-Source: ADKCNb5s44fU1V55unlCHibGowbwfZsUAUCG+mRrzFm6k28avFwW9Q21VZaSw2pk3RYhVY4V/kQksw== X-Received: by 10.98.58.78 with SMTP id h75mr172023pfa.115.1504223531837; Thu, 31 Aug 2017 16:52:11 -0700 (PDT) Received: from Asurada-Nvidia.nvidia.com (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id d6sm859590pfh.113.2017.08.31.16.52.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 31 Aug 2017 16:52:11 -0700 (PDT) From: Nicolin Chen To: rui.zhang@intel.com Cc: edubezval@gmail.com, thierry.reding@gmail.com, jonathanh@nvidia.com, wni@nvidia.com, linux-pm@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org, srikars@nvidia.com Subject: [PATCH] thermal: tegra: dereference the pointer after null check Date: Thu, 31 Aug 2017 16:52:29 -0700 Message-Id: <1504223549-4152-1-git-send-email-nicoleotsuka@gmail.com> X-Mailer: git-send-email 2.1.4 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 The dev pointer is going through a null check after a dereference. So this patch just reverses that. Signed-off-by: Nicolin Chen --- drivers/thermal/tegra/soctherm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/thermal/tegra/soctherm.c b/drivers/thermal/tegra/soctherm.c index 7d2db23..6718799 100644 --- a/drivers/thermal/tegra/soctherm.c +++ b/drivers/thermal/tegra/soctherm.c @@ -478,7 +478,7 @@ static int throttrip_program(struct device *dev, struct soctherm_throt_cfg *stc, int trip_temp) { - struct tegra_soctherm *ts = dev_get_drvdata(dev); + struct tegra_soctherm *ts; int temp, cpu_throt, gpu_throt; unsigned int throt; u32 r, reg_off; @@ -486,6 +486,8 @@ static int throttrip_program(struct device *dev, if (!dev || !sg || !stc || !stc->init) return -EINVAL; + ts = dev_get_drvdata(dev); + temp = enforce_temp_range(dev, trip_temp) / ts->soc->thresh_grain; /* Hardcode LIGHT on LEVEL1 and HEAVY on LEVEL2 */