linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V2] coresight: etm4x: Ensure valid drvdata and clock before clk_put()
@ 2023-08-17  3:59 Anshuman Khandual
  2023-08-17 10:57 ` Suzuki K Poulose
  0 siblings, 1 reply; 2+ messages in thread
From: Anshuman Khandual @ 2023-08-17  3:59 UTC (permalink / raw)
  To: linux-arm-kernel, suzuki.poulose
  Cc: Anshuman Khandual, Mike Leach, James Clark, coresight,
	linux-kernel, Dan Carpenter, Mike Leach

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/
Reviewed-by: James Clark <james.clark@arm.com>
Reviewed-by: Mike Leach <mike.leach@lnaro.org>
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
---
This applies on coresight-next

Changes in V2:

- Dropped drvdata->pclk check for non-NULL
- Replaced IS_ERR() with IS_ERR_OR_NULL() for drvdata->pclk

Changes in V1:

https://lore.kernel.org/all/20230811062738.1066787-1-anshuman.khandual@arm.com/

 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..77b0271ce6eb 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 && !IS_ERR_OR_NULL(drvdata->pclk))
 		clk_put(drvdata->pclk);
 
 	return 0;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH V2] coresight: etm4x: Ensure valid drvdata and clock before clk_put()
  2023-08-17  3:59 [PATCH V2] coresight: etm4x: Ensure valid drvdata and clock before clk_put() Anshuman Khandual
@ 2023-08-17 10:57 ` Suzuki K Poulose
  0 siblings, 0 replies; 2+ messages in thread
From: Suzuki K Poulose @ 2023-08-17 10:57 UTC (permalink / raw)
  To: Anshuman Khandual, linux-arm-kernel
  Cc: Suzuki K Poulose, Mike Leach, Mike Leach, coresight, James Clark,
	Dan Carpenter, linux-kernel

On Thu, 17 Aug 2023 09:29:26 +0530, 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.
> 
> 

Applied, thanks!

[1/1] coresight: etm4x: Ensure valid drvdata and clock before clk_put()
      https://git.kernel.org/coresight/c/a4621fd1d4fd

Best regards,
-- 
Suzuki K Poulose <suzuki.poulose@arm.com>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-08-17 10:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-17  3:59 [PATCH V2] coresight: etm4x: Ensure valid drvdata and clock before clk_put() Anshuman Khandual
2023-08-17 10:57 ` Suzuki K Poulose

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).