From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752010AbdHaXwP (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 X-Google-Smtp-Source: ADKCNb5s44fU1V55unlCHibGowbwfZsUAUCG+mRrzFm6k28avFwW9Q21VZaSw2pk3RYhVY4V/kQksw== 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-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 */ -- 2.1.4