Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp400388imu; Thu, 8 Nov 2018 22:44:48 -0800 (PST) X-Google-Smtp-Source: AJdET5c+dJoEQ/Qb6pyMTZ31f5xYjDrjgzCt403DZyVYx3r1ne/vTkL0SQNbXDcQtI51rg5aWhHO X-Received: by 2002:a62:1f13:: with SMTP id f19-v6mr7806732pff.168.1541745888316; Thu, 08 Nov 2018 22:44:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541745888; cv=none; d=google.com; s=arc-20160816; b=Ual93wnOIJ1EZv+o5k5LLXAdYoJlmpsNzGcCt7z8aIi7sEslqVjC13U59Td1K6+rKX Sknxrw+eT8SNPqHPTt6wFYGQx5g4GTlCozNPlYyCyq2NhbcQF/BAAlZog8c4PCshm0gj knFvgZbUB/Q6oLP4gQ4NfrUUJou9sNx7322ro+c4S+x3Jy2s3KjOsdZKQ+2XgWtHUQSy whTGW6Ze2621Al2EQshi1cv+ncHwCGy+4Hcd7z/5AIskeiwLWp7/DOKazkQ/s+KAre6b 6SNB/p+XdTjDSaeICmj6qaCsb/nPyzZVXoztDBZDtF4o8cwdIs8F71gFQLFvVGJrvSJP oFyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:dkim-signature:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=tTueu11R/PNCDU4V9PphvaVcV/VYKgFDqtfBgN9Cm5Q=; b=L6kBjWLi9wMC91+64Os9tMOJugFfEEgxBmN77tdHImxW0UjMfl7mTVgQ3LfnMzm5i3 j1IVNkuibbt+NL7mld5zDpXKdvuE9j+uQ8xIeygqacEbKNKa303aPqfg5l9HAnOuoALu F0/n0c5HC8OkmZphW1PMKDEXEe+6JJbDcREGDCYLCVgywnMETx5rH+7C/ieby8K/K3qm Is3V94xs0freumaV89ZoQZqRul7VW1YF6csaewHVegYynka6iQiuA7NM42lrag4lwaoD uWdNPFW+BHMznE+BlUYIlO0Zig+EUKssfn8yetpUWsU47gH5EUzvAYv4YQp9sf+OTaa6 x5Rw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=a6tlwzca; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1-v6si7429149plq.243.2018.11.08.22.44.29; Thu, 08 Nov 2018 22:44:48 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=a6tlwzca; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727760AbeKIQXO (ORCPT + 99 others); Fri, 9 Nov 2018 11:23:14 -0500 Received: from hqemgate14.nvidia.com ([216.228.121.143]:4346 "EHLO hqemgate14.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727366AbeKIQXO (ORCPT ); Fri, 9 Nov 2018 11:23:14 -0500 Received: from hqpgpgate102.nvidia.com (Not Verified[216.228.121.13]) by hqemgate14.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Thu, 08 Nov 2018 22:43:49 -0800 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate102.nvidia.com (PGP Universal service); Thu, 08 Nov 2018 22:44:06 -0800 X-PGP-Universal: processed; by hqpgpgate102.nvidia.com on Thu, 08 Nov 2018 22:44:06 -0800 Received: from [10.19.225.182] (10.124.1.5) by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Fri, 9 Nov 2018 06:44:04 +0000 Subject: Re: [PATCH v1 4/4] thermal: tegra: fix coverity defect To: Thierry Reding CC: , , , , References: <1541410354-19090-1-git-send-email-wni@nvidia.com> <1541410354-19090-5-git-send-email-wni@nvidia.com> <20181108123709.GC1340@ulmo> From: Wei Ni Message-ID: Date: Fri, 9 Nov 2018 14:44:01 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <20181108123709.GC1340@ulmo> X-Originating-IP: [10.124.1.5] X-ClientProxiedBy: HQMAIL104.nvidia.com (172.18.146.11) To HQMAIL101.nvidia.com (172.20.187.10) Content-Type: text/plain; charset="windows-1252" Content-Language: en-US Content-Transfer-Encoding: 7bit DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1541745830; bh=tTueu11R/PNCDU4V9PphvaVcV/VYKgFDqtfBgN9Cm5Q=; h=X-PGP-Universal:Subject:To:CC:References:From:Message-ID:Date: User-Agent:MIME-Version:In-Reply-To:X-Originating-IP: X-ClientProxiedBy:Content-Type:Content-Language: Content-Transfer-Encoding; b=a6tlwzcaXiwtao/3GGHi6xVR1wq50o/zlG2B98tnfkB2TFBCXv0c026dInQfmijmT 8IAaZUzFiczQhlP6QUoFptuRn0BVBzVMWOLbrIR8zYt0iJXzQTrfHFMJa3vGpFCvPz vs3CglQrsQjEbXuE3wr3RmQ77Er1BSGCGPSDta2pvcegwPMeg9vc6Ys4qNkzNessMS uu11NtYfRtCiFpnw3JW0kbEVO1kVO6Nxbip0VG/yHJ9cAKU+38xFjyKGZxJ60pMv+u ea6e5auN1UsaDa6lr0D81dejwAn0MU0H5A4eWD8OqEXSHpfeLq74eSgYc06twZ6fkH g8sv18qOKe+cQ== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 8/11/2018 8:37 PM, Thierry Reding wrote: > On Mon, Nov 05, 2018 at 05:32:34PM +0800, Wei Ni wrote: >> Fix dereference dev before null check. >> >> Signed-off-by: Wei Ni >> --- >> 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 3042837364e8..96527df91f2a 100644 >> --- a/drivers/thermal/tegra/soctherm.c >> +++ b/drivers/thermal/tegra/soctherm.c >> @@ -397,7 +397,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; >> @@ -405,6 +405,8 @@ static int throttrip_program(struct device *dev, >> if (!sg || !stc || !stc->init) >> return -EINVAL; >> >> + ts = dev_get_drvdata(dev); > > I think coverity is wrong. How is dev ever going to be NULL in this > case? We allocate all of these struct tegra_thermctl_zone structures in > tegra_soctherm_probe() and assign zone->dev = &pdev->dev, which can > never be NULL. > > And even if it could, the code would've crashed earlier in > tegra_soctherm_probe() already. > > Furthermore, I fail to see how your patch would fix the defect. None of > the checks in the conditional above actually check the dev value. > Yes, you are right, we doesn't need this change. The driver would not pass null dev in any case. And this driver already had a change "1fba81cc09bd thermal: tegra: remove null check for dev pointer" which remove this "dev" checking. Thank. Wei. > Thierry >