From patchwork Thu Jun 21 08:06:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 10479393 X-Patchwork-Delegate: rjw@sisk.pl 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 0068960230 for ; Thu, 21 Jun 2018 08:07:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E5F3A28E6D for ; Thu, 21 Jun 2018 08:07:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DABC928E7A; Thu, 21 Jun 2018 08:07:03 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY 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 8FA5C28E6D for ; Thu, 21 Jun 2018 08:07:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754236AbeFUIG7 (ORCPT ); Thu, 21 Jun 2018 04:06:59 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:55326 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754299AbeFUIGz (ORCPT ); Thu, 21 Jun 2018 04:06:55 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w5L83lv1194174; Thu, 21 Jun 2018 08:06:51 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : mime-version : content-type; s=corp-2017-10-26; bh=9Ht/mkPl86s1BCbAGoe3dwgoZ257OSHm+Wyx7h27ndI=; b=VWsiD3ylmHu7l2XBbWrRrdwAU+2oddp0ttvDX3pgpm8zBYra402niIp0P42WDG3mMSp8 vZHKzTmLWSeMYKwNWMkV7CTYFtqAEvKfzU2bSGdj+1/1t7w9qWTi1vS1Skk6lI25IvVZ 8lXwhNZrnSbl0LrbPlWpLZQovDcnaTdQgMkr0ryv3BKLjUJ0GBFSQSSSiCgFEaJUdvpw zpmo3V6vzpn2R3Shtnu/CHV54dNAh/EnkR3MJmhZU62peW7q+FZE5ePFtgz5A/UEoVE7 7VCCGQniVeK1f2yadKVUg0bUo4wJ5eoN/ndycSinOFYVuhOnm8c4UO729oD4Iuawlj+N yg== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2130.oracle.com with ESMTP id 2jmt01qp5g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 21 Jun 2018 08:06:50 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w5L86nnd005061 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 21 Jun 2018 08:06:49 GMT Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w5L86mUV024679; Thu, 21 Jun 2018 08:06:48 GMT Received: from kili.mountain (/41.202.241.28) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 21 Jun 2018 01:06:48 -0700 Date: Thu, 21 Jun 2018 11:06:41 +0300 From: Dan Carpenter To: Ilia Lin Cc: "Rafael J. Wysocki" , Viresh Kumar , linux-pm@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH] cpufreq: qcom-kryo: Fix error handling in probe() Message-ID: <20180621080618.gzbm3qgbp42pdirg@kili.mountain> MIME-Version: 1.0 Content-Disposition: inline X-Mailer: git-send-email haha only kidding User-Agent: NeoMutt/20170113 (1.7.2) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8930 signatures=668702 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1805220000 definitions=main-1806210091 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 We should return if get_cpu_device() fails or it leads to a NULL dereference. Also dev_pm_opp_of_get_opp_desc_node() returns NULL on error, it never returns error pointers. Fixes: 46e2856b8e18 ("cpufreq: Add Kryo CPU scaling driver") Signed-off-by: Dan Carpenter Acked-by: Viresh Kumar diff --git a/drivers/cpufreq/qcom-cpufreq-kryo.c b/drivers/cpufreq/qcom-cpufreq-kryo.c index d049fe4b80c4..b54049614744 100644 --- a/drivers/cpufreq/qcom-cpufreq-kryo.c +++ b/drivers/cpufreq/qcom-cpufreq-kryo.c @@ -86,8 +86,8 @@ static int qcom_cpufreq_kryo_probe(struct platform_device *pdev) int ret; cpu_dev = get_cpu_device(0); - if (NULL == cpu_dev) - ret = -ENODEV; + if (!cpu_dev) + return -ENODEV; msm8996_version = qcom_cpufreq_kryo_get_msm_id(); if (NUM_OF_MSM8996_VERSIONS == msm8996_version) { @@ -96,8 +96,8 @@ static int qcom_cpufreq_kryo_probe(struct platform_device *pdev) } np = dev_pm_opp_of_get_opp_desc_node(cpu_dev); - if (IS_ERR(np)) - return PTR_ERR(np); + if (!np) + return -ENOENT; ret = of_device_is_compatible(np, "operating-points-v2-kryo-cpu"); if (!ret) {