From patchwork Mon Feb 15 13:59:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Hunter X-Patchwork-Id: 8315561 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 9F81FC02AA for ; Mon, 15 Feb 2016 13:59:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B4E942039C for ; Mon, 15 Feb 2016 13:59:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CCD6A2037C for ; Mon, 15 Feb 2016 13:59:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753328AbcBON72 (ORCPT ); Mon, 15 Feb 2016 08:59:28 -0500 Received: from hqemgate15.nvidia.com ([216.228.121.64]:18196 "EHLO hqemgate15.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753323AbcBON7Z (ORCPT ); Mon, 15 Feb 2016 08:59:25 -0500 Received: from hqnvupgp07.nvidia.com (Not Verified[216.228.121.13]) by hqemgate15.nvidia.com id ; Mon, 15 Feb 2016 05:59:17 -0800 Received: from hqemhub02.nvidia.com ([172.20.150.31]) by hqnvupgp07.nvidia.com (PGP Universal service); Mon, 15 Feb 2016 05:58:31 -0800 X-PGP-Universal: processed; by hqnvupgp07.nvidia.com on Mon, 15 Feb 2016 05:58:31 -0800 Received: from jonathanh-lm.nvidia.com (172.20.144.16) by hqemhub02.nvidia.com (172.20.150.31) with Microsoft SMTP Server (TLS) id 8.3.406.0; Mon, 15 Feb 2016 05:59:24 -0800 From: Jon Hunter To: Viresh Kumar , Nishanth Menon , Stephen Boyd , "Rafael J. Wysocki" CC: linux-pm@vger.kernel.org, linux-tegra@vger.kernel.org, Jon Hunter Subject: [PATCH] PM / OPP: Fix NULL pointer dereference crash when setting the OPP Date: Mon, 15 Feb 2016 13:59:18 +0000 Message-ID: <1455544758-7718-1-git-send-email-jonathanh@nvidia.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1455189959-27944-1-git-send-email-jonathanh@nvidia.com> References: <1455189959-27944-1-git-send-email-jonathanh@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.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 Commit 6a0712f6f199 ("PM / OPP: Add dev_pm_opp_set_rate()") causes a crash on Tegra124 Jetson TK1 when using the DFLL clock source for the CPU. The DFLL manages the voltage itself and so there is no regulator specified for the OPPs and so we get a crash when we try to dereference the regulator pointer. Fix this by checking to see if the regulator IS_ERR_OR_NULL before dereferencing it. Fixes: 6a0712f6f199 ("PM / OPP: Add dev_pm_opp_set_rate()") Signed-off-by: Jon Hunter --- I am not sure why I did not catch this instance of the bug last week when I submitted the patch to fix the NULL pointer dereference in _opp_supported_by_regulators(). May be I forgot to go back and test on HEAD after bisecting? Anyway, both this fix and the one from last week are necessary to get the kernel booting again on Tegra124 Jetson TK1. drivers/base/power/opp/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/base/power/opp/core.c b/drivers/base/power/opp/core.c index d7cd4e265766..82ad5ae72427 100644 --- a/drivers/base/power/opp/core.c +++ b/drivers/base/power/opp/core.c @@ -564,7 +564,7 @@ static int _set_opp_voltage(struct device *dev, struct regulator *reg, int ret; /* Regulator not available for device */ - if (IS_ERR(reg)) { + if (IS_ERR_OR_NULL(reg)) { dev_dbg(dev, "%s: regulator not available: %ld\n", __func__, PTR_ERR(reg)); return 0;