iommu.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iommu/qcom: add missing put_device() call in qcom_iommu_of_xlate()
@ 2020-09-18  1:13 Yu Kuai
  2020-09-21 17:50 ` Will Deacon
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Yu Kuai @ 2020-09-18  1:13 UTC (permalink / raw)
  To: robdclark, will, joro
  Cc: yi.zhang, linux-arm-msm, linux-kernel, iommu, yukuai3, linux-arm-kernel

if of_find_device_by_node() succeed, qcom_iommu_of_xlate() doesn't have
a corresponding put_device(). Thus add put_device() to fix the exception
handling for this function implementation.

Fixes: e86d1aa8b60f ("iommu/arm-smmu: Move Arm SMMU drivers into their own subdirectory")
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
 drivers/iommu/arm/arm-smmu/qcom_iommu.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/iommu/arm/arm-smmu/qcom_iommu.c b/drivers/iommu/arm/arm-smmu/qcom_iommu.c
index 9535a6af7553..7a9594d221e0 100644
--- a/drivers/iommu/arm/arm-smmu/qcom_iommu.c
+++ b/drivers/iommu/arm/arm-smmu/qcom_iommu.c
@@ -584,8 +584,10 @@ static int qcom_iommu_of_xlate(struct device *dev, struct of_phandle_args *args)
 	 * index into qcom_iommu->ctxs:
 	 */
 	if (WARN_ON(asid < 1) ||
-	    WARN_ON(asid > qcom_iommu->num_ctxs))
+	    WARN_ON(asid > qcom_iommu->num_ctxs)) {
+		put_device(&iommu_pdev->dev);
 		return -EINVAL;
+	}
 
 	if (!dev_iommu_priv_get(dev)) {
 		dev_iommu_priv_set(dev, qcom_iommu);
@@ -595,6 +597,7 @@ static int qcom_iommu_of_xlate(struct device *dev, struct of_phandle_args *args)
 		 * banks are ok, but multiple devices are not:
 		 */
 		if (WARN_ON(qcom_iommu != dev_iommu_priv_get(dev)))
+			put_device(&iommu_pdev->dev);
 			return -EINVAL;
 	}
 
-- 
2.25.4

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply related	[flat|nested] 10+ messages in thread
* Re: [PATCH] iommu/qcom: add missing put_device() call in qcom_iommu_of_xlate()
@ 2020-09-18 15:17 Markus Elfring
  0 siblings, 0 replies; 10+ messages in thread
From: Markus Elfring @ 2020-09-18 15:17 UTC (permalink / raw)
  To: Yu Kuai, iommu, linux-arm-kernel, linux-arm-msm
  Cc: Yi Zhang, kernel-janitors, linux-kernel, Will Deacon

…
> +++ b/drivers/iommu/arm/arm-smmu/qcom_iommu.c
> @@ -595,6 +597,7 @@ static int qcom_iommu_of_xlate(struct device *dev, struct of_phandle_args *args)
>  		 * banks are ok, but multiple devices are not:
>  		 */
>  		if (WARN_ON(qcom_iommu != dev_iommu_priv_get(dev)))
> +			put_device(&iommu_pdev->dev);
>  			return -EINVAL;
>  	}

* Would there be a need to use curly brackets for such an if branch?

* I suggest to add a jump target so that a bit of common exception handling code
  can be better reused for this function implementation.

Regards,
Markus
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

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

end of thread, other threads:[~2020-09-29  1:38 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-18  1:13 [PATCH] iommu/qcom: add missing put_device() call in qcom_iommu_of_xlate() Yu Kuai
2020-09-21 17:50 ` Will Deacon
2020-09-21 18:27   ` Rob Clark
2020-09-21 18:33     ` Rob Clark
2020-09-21 19:13 ` kernel test robot
2020-09-21 20:45   ` Will Deacon
2020-09-28 23:08     ` Will Deacon
2020-09-29  1:37       ` yukuai (C)
2020-09-23  4:32 ` kernel test robot
2020-09-18 15:17 Markus Elfring

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).