From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 188B2C433EF for ; Tue, 22 Mar 2022 13:33:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 736CC6B0072; Tue, 22 Mar 2022 09:33:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6E5846B0073; Tue, 22 Mar 2022 09:33:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 585206B0074; Tue, 22 Mar 2022 09:33:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.25]) by kanga.kvack.org (Postfix) with ESMTP id 4648A6B0072 for ; Tue, 22 Mar 2022 09:33:33 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 025B822EA9 for ; Tue, 22 Mar 2022 13:33:32 +0000 (UTC) X-FDA: 79272114264.01.26DB3DF Received: from alexa-out-sd-01.qualcomm.com (alexa-out-sd-01.qualcomm.com [199.106.114.38]) by imf21.hostedemail.com (Postfix) with ESMTP id 452111C0029 for ; Tue, 22 Mar 2022 13:33:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1647956012; x=1679492012; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=EpjDJL9b1DB4OYH9I+oRAIgdCdeoiFi2FPBz6B87lSk=; b=G3n67OADRWAqxpu3fiuSayv0fAMjyCQnLJOsqTIsPlvF7Kbz1yq/xUNN aALtgERnhJCUQCjT/r24xUv1/ii8s1C5MefXtBDg1JJHPEq3mic0lH869 VjGuhbASyJvNoNSsW5T3KMPdIwpx8ab2BZ25xf4kbM+s6qV2xnxQKZoy6 o=; Received: from unknown (HELO ironmsg02-sd.qualcomm.com) ([10.53.140.142]) by alexa-out-sd-01.qualcomm.com with ESMTP; 22 Mar 2022 06:33:30 -0700 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg02-sd.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Mar 2022 06:33:29 -0700 Received: from nalasex01a.na.qualcomm.com (10.47.209.196) by nasanex01c.na.qualcomm.com (10.47.97.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Tue, 22 Mar 2022 06:33:29 -0700 Received: from [10.216.60.158] (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Tue, 22 Mar 2022 06:33:26 -0700 Message-ID: Date: Tue, 22 Mar 2022 19:03:23 +0530 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: Re: [linux-next:master 8752/11953] sound/soc/codecs/lpass-macro-common.c:53 lpass_macro_pds_init() warn: passing zero to 'ERR_PTR' Content-Language: en-US To: Dan Carpenter , CC: , , Linux Memory Management List , Mark Brown , Venkata Prasad Potturu References: <202203111754.32TAMFKD-lkp@intel.com> From: Srinivasa Rao Mandadapu Organization: Qualcomm In-Reply-To: <202203111754.32TAMFKD-lkp@intel.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01a.na.qualcomm.com (10.47.209.196) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=quicinc.com header.s=qcdkim header.b=G3n67OAD; spf=pass (imf21.hostedemail.com: domain of quic_srivasam@quicinc.com designates 199.106.114.38 as permitted sender) smtp.mailfrom=quic_srivasam@quicinc.com; dmarc=pass (policy=none) header.from=quicinc.com X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 452111C0029 X-Stat-Signature: ceeo9h7w7ktj1nstgby7q9pepzq3qenj X-HE-Tag: 1647956012-235301 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 3/11/2022 5:23 PM, Dan Carpenter wrote: Thanks for Your time and valuable inputs Dan!! > tree: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master > head: 71941773e143369a73c9c4a3b62fbb60736a1182 > commit: 9e3d83c52844f955aa2975f78cee48bf9f72f5e1 [8752/11953] ASoC: codecs: Add power domains support in digital macro codecs > config: arm-randconfig-m031-20220310 (https://download.01.org/0day-ci/archive/20220311/202203111754.32TAMFKD-lkp@intel.com/config) > compiler: arm-linux-gnueabi-gcc (GCC) 11.2.0 > > If you fix the issue, kindly add following tag as appropriate > Reported-by: kernel test robot > Reported-by: Dan Carpenter > > smatch warnings: > sound/soc/codecs/lpass-macro-common.c:53 lpass_macro_pds_init() warn: passing zero to 'ERR_PTR' > > vim +/ERR_PTR +53 sound/soc/codecs/lpass-macro-common.c > > 9e3d83c52844f95 Srinivasa Rao Mandadapu 2022-02-26 14 struct lpass_macro *lpass_macro_pds_init(struct device *dev) > 9e3d83c52844f95 Srinivasa Rao Mandadapu 2022-02-26 15 { > 9e3d83c52844f95 Srinivasa Rao Mandadapu 2022-02-26 16 struct lpass_macro *l_pds; > 9e3d83c52844f95 Srinivasa Rao Mandadapu 2022-02-26 17 int ret; > 9e3d83c52844f95 Srinivasa Rao Mandadapu 2022-02-26 18 > 9e3d83c52844f95 Srinivasa Rao Mandadapu 2022-02-26 19 if (!of_find_property(dev->of_node, "power-domains", NULL)) > 9e3d83c52844f95 Srinivasa Rao Mandadapu 2022-02-26 20 return NULL; > > Returning NULL here will lead to a crash in tx_macro_runtime_resume() > > When a function returns a mix of NULL and error pointers, then NULL > means the feature is deliberately disabled. It's not an error, it's a > deliberate choice by the distro or sys admin. The caller has to > be written to allow the feature to be disabled. > > An example of this might be LEDs. Maybe people don't want LEDs so code > has to asume that the led->ops pointer might be NULL and check for that > before dereferencing it. Actually, it's optional here. For some targets, with lpass ADSP enabled, power domains are not required. So is the reason, returning NULL Here. > > 9e3d83c52844f95 Srinivasa Rao Mandadapu 2022-02-26 21 > 9e3d83c52844f95 Srinivasa Rao Mandadapu 2022-02-26 22 l_pds = devm_kzalloc(dev, sizeof(*l_pds), GFP_KERNEL); > 9e3d83c52844f95 Srinivasa Rao Mandadapu 2022-02-26 23 if (!l_pds) > 9e3d83c52844f95 Srinivasa Rao Mandadapu 2022-02-26 24 return ERR_PTR(-ENOMEM); > > Good. > > 9e3d83c52844f95 Srinivasa Rao Mandadapu 2022-02-26 25 > 9e3d83c52844f95 Srinivasa Rao Mandadapu 2022-02-26 26 l_pds->macro_pd = dev_pm_domain_attach_by_name(dev, "macro"); > 9e3d83c52844f95 Srinivasa Rao Mandadapu 2022-02-26 27 if (IS_ERR_OR_NULL(l_pds->macro_pd)) > 9e3d83c52844f95 Srinivasa Rao Mandadapu 2022-02-26 28 return NULL; > > If this feature is optional then it should be: > > if (IS_ERR_OR_NULL(l_pds->macro_pd)) > return ERR_CAST(l_pds->macro_pd); > > The admin deliberately chose to enable the feature so we can't just > ignore errors and convert them to NULL. Here it's not optional, if power domains feature is available then macro and dcodec power domains should be present. So will update it like below. if (IS_ERR_OR_NULL(l_pds->macro_pd)) { ret = PTR_ERR(l_pds->macro_pd); goto macro_err; } > > 9e3d83c52844f95 Srinivasa Rao Mandadapu 2022-02-26 29 > 9e3d83c52844f95 Srinivasa Rao Mandadapu 2022-02-26 30 ret = pm_runtime_get_sync(l_pds->macro_pd); > > This is correct, but the documentation for pm_runtime_get_sync() says to > consider pm_runtime_resume_and_get() instead. The error handling is > slightly different and easier. I forget the details. Okay. Will update accordingly. > > 9e3d83c52844f95 Srinivasa Rao Mandadapu 2022-02-26 31 if (ret < 0) { > 9e3d83c52844f95 Srinivasa Rao Mandadapu 2022-02-26 32 pm_runtime_put_noidle(l_pds->macro_pd); > 9e3d83c52844f95 Srinivasa Rao Mandadapu 2022-02-26 33 goto macro_err; > 9e3d83c52844f95 Srinivasa Rao Mandadapu 2022-02-26 34 } > 9e3d83c52844f95 Srinivasa Rao Mandadapu 2022-02-26 35 > 9e3d83c52844f95 Srinivasa Rao Mandadapu 2022-02-26 36 l_pds->dcodec_pd = dev_pm_domain_attach_by_name(dev, "dcodec"); > 9e3d83c52844f95 Srinivasa Rao Mandadapu 2022-02-26 37 if (IS_ERR_OR_NULL(l_pds->dcodec_pd)) > 9e3d83c52844f95 Srinivasa Rao Mandadapu 2022-02-26 38 goto dcodec_err; > > Again this IS_ERR_OR_NULL() check needs to preserve the error codes: > > if (IS_ERR_OR_NULL(l_pds->dcodec_pd)) { > ret = PTR_ERR(l_pds->dcodec_pd); > goto dcodec_err; > } Okay. Will update accordingly. > > 9e3d83c52844f95 Srinivasa Rao Mandadapu 2022-02-26 39 > 9e3d83c52844f95 Srinivasa Rao Mandadapu 2022-02-26 40 ret = pm_runtime_get_sync(l_pds->dcodec_pd); > 9e3d83c52844f95 Srinivasa Rao Mandadapu 2022-02-26 41 if (ret < 0) { > 9e3d83c52844f95 Srinivasa Rao Mandadapu 2022-02-26 42 pm_runtime_put_noidle(l_pds->dcodec_pd); > 9e3d83c52844f95 Srinivasa Rao Mandadapu 2022-02-26 43 goto dcodec_sync_err; > 9e3d83c52844f95 Srinivasa Rao Mandadapu 2022-02-26 44 } > 9e3d83c52844f95 Srinivasa Rao Mandadapu 2022-02-26 45 return l_pds; > 9e3d83c52844f95 Srinivasa Rao Mandadapu 2022-02-26 46 > 9e3d83c52844f95 Srinivasa Rao Mandadapu 2022-02-26 47 dcodec_sync_err: > 9e3d83c52844f95 Srinivasa Rao Mandadapu 2022-02-26 48 dev_pm_domain_detach(l_pds->dcodec_pd, false); > 9e3d83c52844f95 Srinivasa Rao Mandadapu 2022-02-26 49 dcodec_err: > 9e3d83c52844f95 Srinivasa Rao Mandadapu 2022-02-26 50 pm_runtime_put(l_pds->macro_pd); > 9e3d83c52844f95 Srinivasa Rao Mandadapu 2022-02-26 51 macro_err: > 9e3d83c52844f95 Srinivasa Rao Mandadapu 2022-02-26 52 dev_pm_domain_detach(l_pds->macro_pd, false); > 9e3d83c52844f95 Srinivasa Rao Mandadapu 2022-02-26 @53 return ERR_PTR(ret); > 9e3d83c52844f95 Srinivasa Rao Mandadapu 2022-02-26 54 } > > --- > 0-DAY CI Kernel Test Service > https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org >