Message ID | 20230811062738.1066787-1-anshuman.khandual@arm.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp938568vqi; Fri, 11 Aug 2023 01:31:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHVKtBLkPUbGeyEg5V1BQGhlvPe6tri5B6W59rlAovgxP/Bt4LRa0aRq5dqc4GuCikw3l7T X-Received: by 2002:a05:6808:2749:b0:3a7:6acd:c7c with SMTP id eh9-20020a056808274900b003a76acd0c7cmr1083821oib.18.1691742707722; Fri, 11 Aug 2023 01:31:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691742707; cv=none; d=google.com; s=arc-20160816; b=gOB0I9nbS36MpkpShcTLLzaARxp9JDcD2ugvfXe1y6LiUi1LqdtT5stFqq6/DWmouh pG3Tj9KFKbL2X6FfTs7LuasJLUSceCx/lTaDvAPDoJSW5nUZu6FEpFtvzauP+UuCRCm0 eFSkT3j8pEwvHZbHXJOtrTTNEwhYIpp0IRfhu+WGkZqmdbEl37J47kKT2/m3BzKE6sK7 urAC8DK2ElaqKe9vCKE2gskJCQuZ4myrDo+ggP0J9iplFv28FRqapOr8XH0TzLt02sPE 0xet+Z8qcinrJFS0X3yofbLEU9lnThtxkRCkYHD0Hhvt0dhp+lDFtGa7FpbS5mt+G/vS gmeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=5uFEHPusVzK+cz4w2QMkFvLc2oKhwqsKv8Klu8rPkF4=; fh=NG8HHJPNbnIrNE7nbx+BxkF2xZxjX/Fgug8GPYbEwLQ=; b=biP437S1+8qPbT8fYGi9exjqvd/lhIu8uhK5gqUlGJkWw5WD1cLF7/F9m64k/wm70s wD67rLUoJUgXQZzeD/PQ/3/3yMb7YO/Q8jRrywU4XaUBUvz9Rynp5lon9KEkjGsSfHW7 mt6N5tLjJGyQzy151uVhNLyMi3Mi10kFq8jlGtPXauNqS/unbDsmkLRG4Q459JXT3qq1 eenH5ERPwmaKyl4XmG968DQ87Ds+AIStwVreyHOI6zBx0K8BmUCqzWiYiiEicgLiGr3o CJhArzZ0siu6Skv3HI+J2ei9kvpTDWkUp1DT0xyzr5S38d2aWl3/2LaLb5A5Z7fsE5V1 A6Ww== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 63-20020a630142000000b00563df8b134esi3002408pgb.213.2023.08.11.01.31.34; Fri, 11 Aug 2023 01:31:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233728AbjHKG1x (ORCPT <rfc822;shaohuahua6@gmail.com> + 99 others); Fri, 11 Aug 2023 02:27:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229517AbjHKG1w (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 11 Aug 2023 02:27:52 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D054D2D4F for <linux-kernel@vger.kernel.org>; Thu, 10 Aug 2023 23:27:51 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D43BBD75; Thu, 10 Aug 2023 23:28:33 -0700 (PDT) Received: from a077893.arm.com (unknown [10.163.54.13]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 498B03F59C; Thu, 10 Aug 2023 23:27:47 -0700 (PDT) From: Anshuman Khandual <anshuman.khandual@arm.com> To: linux-arm-kernel@lists.infradead.org, suzuki.poulose@arm.com Cc: Anshuman Khandual <anshuman.khandual@arm.com>, Mike Leach <mike.leach@linaro.org>, James Clark <james.clark@arm.com>, coresight@lists.linaro.org, linux-kernel@vger.kernel.org, Dan Carpenter <dan.carpenter@linaro.org> Subject: [PATCH] coresight: etm4x: Ensure valid drvdata and clock before clk_put() Date: Fri, 11 Aug 2023 11:57:38 +0530 Message-Id: <20230811062738.1066787-1-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773920801082769210 X-GMAIL-MSGID: 1773920801082769210 |
Series |
coresight: etm4x: Ensure valid drvdata and clock before clk_put()
|
|
Commit Message
Anshuman Khandual
Aug. 11, 2023, 6:27 a.m. UTC
This validates 'drvdata' and 'drvdata->pclk' clock before calling clk_put()
in etm4_remove_platform_dev(). The problem was detected using Smatch static
checker as reported.
Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
Cc: Mike Leach <mike.leach@linaro.org>
Cc: James Clark <james.clark@arm.com>
Cc: coresight@lists.linaro.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lists.linaro.org/archives/list/coresight@lists.linaro.org/thread/G4N6P4OXELPLLQSNU3GU2MR4LOLRXRMJ/
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
---
This applies on coresight-next
drivers/hwtracing/coresight/coresight-etm4x-core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On 11/08/2023 07:27, Anshuman Khandual wrote: > This validates 'drvdata' and 'drvdata->pclk' clock before calling clk_put() > in etm4_remove_platform_dev(). The problem was detected using Smatch static > checker as reported. > > Cc: Suzuki K Poulose <suzuki.poulose@arm.com> > Cc: Mike Leach <mike.leach@linaro.org> > Cc: James Clark <james.clark@arm.com> > Cc: coresight@lists.linaro.org > Cc: linux-arm-kernel@lists.infradead.org > Cc: linux-kernel@vger.kernel.org > Reported-by: Dan Carpenter <dan.carpenter@linaro.org> > Closes: https://lists.linaro.org/archives/list/coresight@lists.linaro.org/thread/G4N6P4OXELPLLQSNU3GU2MR4LOLRXRMJ/ > Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com> > --- > This applies on coresight-next > > drivers/hwtracing/coresight/coresight-etm4x-core.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/hwtracing/coresight/coresight-etm4x-core.c > index 703b6fcbb6a5..eb412ce302cc 100644 > --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c > +++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c > @@ -2269,7 +2269,7 @@ static int __exit etm4_remove_platform_dev(struct platform_device *pdev) > etm4_remove_dev(drvdata); > pm_runtime_disable(&pdev->dev); > > - if (drvdata->pclk) > + if (drvdata && drvdata->pclk && !IS_ERR(drvdata->pclk)) > clk_put(drvdata->pclk); > > return 0; It could be !IS_ERR_OR_NULL(drvdata->pclk), but I wouldn't bother changing it at this point. Reviewed-by: James Clark <james.clark@arm.com>
On Fri, 11 Aug 2023 at 07:27, Anshuman Khandual <anshuman.khandual@arm.com> wrote: > > This validates 'drvdata' and 'drvdata->pclk' clock before calling clk_put() > in etm4_remove_platform_dev(). The problem was detected using Smatch static > checker as reported. > > Cc: Suzuki K Poulose <suzuki.poulose@arm.com> > Cc: Mike Leach <mike.leach@linaro.org> > Cc: James Clark <james.clark@arm.com> > Cc: coresight@lists.linaro.org > Cc: linux-arm-kernel@lists.infradead.org > Cc: linux-kernel@vger.kernel.org > Reported-by: Dan Carpenter <dan.carpenter@linaro.org> > Closes: https://lists.linaro.org/archives/list/coresight@lists.linaro.org/thread/G4N6P4OXELPLLQSNU3GU2MR4LOLRXRMJ/ > Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com> > --- > This applies on coresight-next > > drivers/hwtracing/coresight/coresight-etm4x-core.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/hwtracing/coresight/coresight-etm4x-core.c > index 703b6fcbb6a5..eb412ce302cc 100644 > --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c > +++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c > @@ -2269,7 +2269,7 @@ static int __exit etm4_remove_platform_dev(struct platform_device *pdev) > etm4_remove_dev(drvdata); > pm_runtime_disable(&pdev->dev); > > - if (drvdata->pclk) > + if (drvdata && drvdata->pclk && !IS_ERR(drvdata->pclk)) > clk_put(drvdata->pclk); > > return 0; > -- > 2.25.1 > Reviewed-by: Mike Leach <mike.leach@lnaro.org>
On 11/08/2023 09:39, James Clark wrote: > > > On 11/08/2023 07:27, Anshuman Khandual wrote: >> This validates 'drvdata' and 'drvdata->pclk' clock before calling clk_put() >> in etm4_remove_platform_dev(). The problem was detected using Smatch static >> checker as reported. >> >> Cc: Suzuki K Poulose <suzuki.poulose@arm.com> >> Cc: Mike Leach <mike.leach@linaro.org> >> Cc: James Clark <james.clark@arm.com> >> Cc: coresight@lists.linaro.org >> Cc: linux-arm-kernel@lists.infradead.org >> Cc: linux-kernel@vger.kernel.org >> Reported-by: Dan Carpenter <dan.carpenter@linaro.org> >> Closes: https://lists.linaro.org/archives/list/coresight@lists.linaro.org/thread/G4N6P4OXELPLLQSNU3GU2MR4LOLRXRMJ/ >> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com> >> --- >> This applies on coresight-next >> >> drivers/hwtracing/coresight/coresight-etm4x-core.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/hwtracing/coresight/coresight-etm4x-core.c >> index 703b6fcbb6a5..eb412ce302cc 100644 >> --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c >> +++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c >> @@ -2269,7 +2269,7 @@ static int __exit etm4_remove_platform_dev(struct platform_device *pdev) >> etm4_remove_dev(drvdata); >> pm_runtime_disable(&pdev->dev); >> >> - if (drvdata->pclk) >> + if (drvdata && drvdata->pclk && !IS_ERR(drvdata->pclk)) >> clk_put(drvdata->pclk); >> >> return 0; > > It could be !IS_ERR_OR_NULL(drvdata->pclk), but I wouldn't bother > changing it at this point. +1, please could we have that. Someone else will run a code scanner and send a patch later. Given this is straight and easy change, lets do it in the first place. Cheers Suzuki > > Reviewed-by: James Clark <james.clark@arm.com>
On 8/11/23 14:39, Suzuki K Poulose wrote: > On 11/08/2023 09:39, James Clark wrote: >> >> >> On 11/08/2023 07:27, Anshuman Khandual wrote: >>> This validates 'drvdata' and 'drvdata->pclk' clock before calling clk_put() >>> in etm4_remove_platform_dev(). The problem was detected using Smatch static >>> checker as reported. >>> >>> Cc: Suzuki K Poulose <suzuki.poulose@arm.com> >>> Cc: Mike Leach <mike.leach@linaro.org> >>> Cc: James Clark <james.clark@arm.com> >>> Cc: coresight@lists.linaro.org >>> Cc: linux-arm-kernel@lists.infradead.org >>> Cc: linux-kernel@vger.kernel.org >>> Reported-by: Dan Carpenter <dan.carpenter@linaro.org> >>> Closes: https://lists.linaro.org/archives/list/coresight@lists.linaro.org/thread/G4N6P4OXELPLLQSNU3GU2MR4LOLRXRMJ/ >>> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com> >>> --- >>> This applies on coresight-next >>> >>> drivers/hwtracing/coresight/coresight-etm4x-core.c | 2 +- >>> 1 file changed, 1 insertion(+), 1 deletion(-) >>> >>> diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/hwtracing/coresight/coresight-etm4x-core.c >>> index 703b6fcbb6a5..eb412ce302cc 100644 >>> --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c >>> +++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c >>> @@ -2269,7 +2269,7 @@ static int __exit etm4_remove_platform_dev(struct platform_device *pdev) >>> etm4_remove_dev(drvdata); >>> pm_runtime_disable(&pdev->dev); >>> - if (drvdata->pclk) >>> + if (drvdata && drvdata->pclk && !IS_ERR(drvdata->pclk)) >>> clk_put(drvdata->pclk); >>> return 0; >> >> It could be !IS_ERR_OR_NULL(drvdata->pclk), but I wouldn't bother >> changing it at this point. > > +1, please could we have that. Someone else will run a code scanner and > send a patch later. Given this is straight and easy change, lets do it > in the first place. But we already have a drvdata->pclk validation check before IS_ERR(). Would not _OR_NULL be redundant ?
On Fri, Aug 11, 2023 at 10:09:43AM +0100, Suzuki K Poulose wrote: > On 11/08/2023 09:39, James Clark wrote: > > > > > > On 11/08/2023 07:27, Anshuman Khandual wrote: > > > This validates 'drvdata' and 'drvdata->pclk' clock before calling clk_put() > > > in etm4_remove_platform_dev(). The problem was detected using Smatch static > > > checker as reported. > > > > > > Cc: Suzuki K Poulose <suzuki.poulose@arm.com> > > > Cc: Mike Leach <mike.leach@linaro.org> > > > Cc: James Clark <james.clark@arm.com> > > > Cc: coresight@lists.linaro.org > > > Cc: linux-arm-kernel@lists.infradead.org > > > Cc: linux-kernel@vger.kernel.org > > > Reported-by: Dan Carpenter <dan.carpenter@linaro.org> > > > Closes: https://lists.linaro.org/archives/list/coresight@lists.linaro.org/thread/G4N6P4OXELPLLQSNU3GU2MR4LOLRXRMJ/ > > > Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com> > > > --- > > > This applies on coresight-next > > > > > > drivers/hwtracing/coresight/coresight-etm4x-core.c | 2 +- > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/hwtracing/coresight/coresight-etm4x-core.c > > > index 703b6fcbb6a5..eb412ce302cc 100644 > > > --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c > > > +++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c > > > @@ -2269,7 +2269,7 @@ static int __exit etm4_remove_platform_dev(struct platform_device *pdev) > > > etm4_remove_dev(drvdata); > > > pm_runtime_disable(&pdev->dev); > > > - if (drvdata->pclk) > > > + if (drvdata && drvdata->pclk && !IS_ERR(drvdata->pclk)) > > > clk_put(drvdata->pclk); > > > return 0; > > > > It could be !IS_ERR_OR_NULL(drvdata->pclk), but I wouldn't bother > > changing it at this point. > > +1, please could we have that. Someone else will run a code scanner and > send a patch later. Given this is straight and easy change, lets do it > in the first place. drvdata->pclk can't actually be an error pointer. probe() will correctly not allow that. All the IS_ERR(drvdata->pclk) checks should be removed except for the first check in probe(). There is also no need to check "drvdata->pclk" for NULL because clk_put() accepts NULL pointers. (Returning NULL means the clk subsystem has been disabled deliberately). Also drvdata can't actually be NULL either. regards, dan carpenter
On 11/08/2023 10:22, Anshuman Khandual wrote: > > > On 8/11/23 14:39, Suzuki K Poulose wrote: >> On 11/08/2023 09:39, James Clark wrote: >>> >>> >>> On 11/08/2023 07:27, Anshuman Khandual wrote: >>>> This validates 'drvdata' and 'drvdata->pclk' clock before calling clk_put() >>>> in etm4_remove_platform_dev(). The problem was detected using Smatch static >>>> checker as reported. >>>> >>>> Cc: Suzuki K Poulose <suzuki.poulose@arm.com> >>>> Cc: Mike Leach <mike.leach@linaro.org> >>>> Cc: James Clark <james.clark@arm.com> >>>> Cc: coresight@lists.linaro.org >>>> Cc: linux-arm-kernel@lists.infradead.org >>>> Cc: linux-kernel@vger.kernel.org >>>> Reported-by: Dan Carpenter <dan.carpenter@linaro.org> >>>> Closes: https://lists.linaro.org/archives/list/coresight@lists.linaro.org/thread/G4N6P4OXELPLLQSNU3GU2MR4LOLRXRMJ/ >>>> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com> >>>> --- >>>> This applies on coresight-next >>>> >>>> drivers/hwtracing/coresight/coresight-etm4x-core.c | 2 +- >>>> 1 file changed, 1 insertion(+), 1 deletion(-) >>>> >>>> diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/hwtracing/coresight/coresight-etm4x-core.c >>>> index 703b6fcbb6a5..eb412ce302cc 100644 >>>> --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c >>>> +++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c >>>> @@ -2269,7 +2269,7 @@ static int __exit etm4_remove_platform_dev(struct platform_device *pdev) >>>> etm4_remove_dev(drvdata); >>>> pm_runtime_disable(&pdev->dev); >>>> - if (drvdata->pclk) >>>> + if (drvdata && drvdata->pclk && !IS_ERR(drvdata->pclk)) >>>> clk_put(drvdata->pclk); >>>> return 0; >>> >>> It could be !IS_ERR_OR_NULL(drvdata->pclk), but I wouldn't bother >>> changing it at this point. >> >> +1, please could we have that. Someone else will run a code scanner and >> send a patch later. Given this is straight and easy change, lets do it >> in the first place. > > But we already have a drvdata->pclk validation check before IS_ERR(). > Would not _OR_NULL be redundant ? I meant that it could be replaced with the single check: if (drvdata && !IS_ERR_OR_NULL(drvdata->pclk)) clk_put(drvdata->pclk); As Dan mentions it can't be an error pointer anyway, but leaving it like this could just be considered defensive coding.
On 8/11/23 15:44, James Clark wrote: > > > On 11/08/2023 10:22, Anshuman Khandual wrote: >> >> >> On 8/11/23 14:39, Suzuki K Poulose wrote: >>> On 11/08/2023 09:39, James Clark wrote: >>>> >>>> >>>> On 11/08/2023 07:27, Anshuman Khandual wrote: >>>>> This validates 'drvdata' and 'drvdata->pclk' clock before calling clk_put() >>>>> in etm4_remove_platform_dev(). The problem was detected using Smatch static >>>>> checker as reported. >>>>> >>>>> Cc: Suzuki K Poulose <suzuki.poulose@arm.com> >>>>> Cc: Mike Leach <mike.leach@linaro.org> >>>>> Cc: James Clark <james.clark@arm.com> >>>>> Cc: coresight@lists.linaro.org >>>>> Cc: linux-arm-kernel@lists.infradead.org >>>>> Cc: linux-kernel@vger.kernel.org >>>>> Reported-by: Dan Carpenter <dan.carpenter@linaro.org> >>>>> Closes: https://lists.linaro.org/archives/list/coresight@lists.linaro.org/thread/G4N6P4OXELPLLQSNU3GU2MR4LOLRXRMJ/ >>>>> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com> >>>>> --- >>>>> This applies on coresight-next >>>>> >>>>> drivers/hwtracing/coresight/coresight-etm4x-core.c | 2 +- >>>>> 1 file changed, 1 insertion(+), 1 deletion(-) >>>>> >>>>> diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/hwtracing/coresight/coresight-etm4x-core.c >>>>> index 703b6fcbb6a5..eb412ce302cc 100644 >>>>> --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c >>>>> +++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c >>>>> @@ -2269,7 +2269,7 @@ static int __exit etm4_remove_platform_dev(struct platform_device *pdev) >>>>> etm4_remove_dev(drvdata); >>>>> pm_runtime_disable(&pdev->dev); >>>>> - if (drvdata->pclk) >>>>> + if (drvdata && drvdata->pclk && !IS_ERR(drvdata->pclk)) >>>>> clk_put(drvdata->pclk); >>>>> return 0; >>>> >>>> It could be !IS_ERR_OR_NULL(drvdata->pclk), but I wouldn't bother >>>> changing it at this point. >>> >>> +1, please could we have that. Someone else will run a code scanner and >>> send a patch later. Given this is straight and easy change, lets do it >>> in the first place. >> >> But we already have a drvdata->pclk validation check before IS_ERR(). >> Would not _OR_NULL be redundant ? > > I meant that it could be replaced with the single check: > > if (drvdata && !IS_ERR_OR_NULL(drvdata->pclk)) > clk_put(drvdata->pclk); > > As Dan mentions it can't be an error pointer anyway, but leaving it like > this could just be considered defensive coding. Let's just go with the above change as you had suggested unless there is any particular objection. if (drvdata && !IS_ERR_OR_NULL(drvdata->pclk)) clk_put(drvdata->pclk);
diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/hwtracing/coresight/coresight-etm4x-core.c index 703b6fcbb6a5..eb412ce302cc 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c +++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c @@ -2269,7 +2269,7 @@ static int __exit etm4_remove_platform_dev(struct platform_device *pdev) etm4_remove_dev(drvdata); pm_runtime_disable(&pdev->dev); - if (drvdata->pclk) + if (drvdata && drvdata->pclk && !IS_ERR(drvdata->pclk)) clk_put(drvdata->pclk); return 0;