public inbox for iommu@lists.linux-foundation.org
 help / color / mirror / Atom feed
* Re: [PATCH v2] iommu/qcom: Fix local_base status check
@ 2020-04-19 12:32 Markus Elfring
  2020-04-19 13:10 ` Markus Elfring
  0 siblings, 1 reply; 7+ messages in thread
From: Markus Elfring @ 2020-04-19 12:32 UTC (permalink / raw)
  To: Tang Bin, iommu, linux-arm-msm, Andy Gross, Bjorn Andersson,
	Jörg Rödel, Rob Clark
  Cc: kernel-janitors, linux-kernel

> The function qcom_iommu_device_probe() does not perform sufficient
> error checking after executing devm_ioremap_resource(), which can
> result in crashes if a critical error path is encountered.

Your update suggestion will be rechecked once more.

* Can it be that the patch would need a higher version number
  according to previous review comments?

* Would you like to adjust the patch subject?


…
> +++ b/drivers/iommu/qcom_iommu.c
> @@ -813,8 +813,11 @@ static int qcom_iommu_device_probe(struct platform_device *pdev)
>  	qcom_iommu->dev = dev;
>
>  	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -	if (res)

I find the deletion of this check appropriate.


> +	if (res) {
>  		qcom_iommu->local_base = devm_ioremap_resource(dev, res);

But I do not see a need to preserve such a check because this function
performs input parameter validation.
https://elixir.bootlin.com/linux/v5.7-rc1/source/lib/devres.c#L116
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/lib/devres.c?id=50cc09c18985eacbbd666acfd7be2391394733f5#n116

Please take another look at a corresponding usage example.

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

^ permalink raw reply	[flat|nested] 7+ messages in thread
* [PATCH v2]iommu/qcom:fix local_base status check
@ 2020-04-18 13:47 Tang Bin
  2020-04-20  4:52 ` Bjorn Andersson
  2020-05-01 11:37 ` Joerg Roedel
  0 siblings, 2 replies; 7+ messages in thread
From: Tang Bin @ 2020-04-18 13:47 UTC (permalink / raw)
  To: joro, agross, bjorn.andersson, robdclark
  Cc: linux-arm-msm, iommu, linux-kernel, Tang Bin

The function qcom_iommu_device_probe() does not perform sufficient
error checking after executing devm_ioremap_resource(), which can
result in crashes if a critical error path is encountered.

Fixes: 0ae349a0f33f ("iommu/qcom: Add qcom_iommu")

Signed-off-by: Tang Bin <tangbin@cmss.chinamobile.com>
---
v2:
 - fix commit message and add fixed tag
---
 drivers/iommu/qcom_iommu.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/iommu/qcom_iommu.c b/drivers/iommu/qcom_iommu.c
index 4328da0b0..b160cf140 100644
--- a/drivers/iommu/qcom_iommu.c
+++ b/drivers/iommu/qcom_iommu.c
@@ -813,8 +813,11 @@ static int qcom_iommu_device_probe(struct platform_device *pdev)
 	qcom_iommu->dev = dev;
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (res)
+	if (res) {
 		qcom_iommu->local_base = devm_ioremap_resource(dev, res);
+		if (IS_ERR(qcom_iommu->local_base))
+			return PTR_ERR(qcom_iommu->local_base);
+	}
 
 	qcom_iommu->iface_clk = devm_clk_get(dev, "iface");
 	if (IS_ERR(qcom_iommu->iface_clk)) {
-- 
2.20.1.windows.1



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

^ permalink raw reply related	[flat|nested] 7+ messages in thread
* Re: [PATCH v2] iommu/qcom: Fix local_base status check
@ 2020-04-03 17:20 Markus Elfring
  0 siblings, 0 replies; 7+ messages in thread
From: Markus Elfring @ 2020-04-03 17:20 UTC (permalink / raw)
  To: Tang Bin, iommu, linux-arm-msm, Andy Gross, Bjorn Andersson,
	Jörg Rödel, Rob Clark
  Cc: kernel-janitors, linux-kernel

> Release resources when exiting on error.

I have got doubts that such a change description fits to
the proposed source code adjustment.


…
> +++ b/drivers/iommu/qcom_iommu.c
> @@ -813,8 +813,11 @@ static int qcom_iommu_device_probe(struct platform_device *pdev)
>  	qcom_iommu->dev = dev;
>
>  	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -	if (res)
> +	if (res) {
>  		qcom_iommu->local_base = devm_ioremap_resource(dev, res);
> +		if (IS_ERR(qcom_iommu->local_base))
> +			return PTR_ERR(qcom_iommu->local_base);
> +	}
>
>  	qcom_iommu->iface_clk = devm_clk_get(dev, "iface");
…

Will the commit message be improved any further?

Would you like to add the tag “Fixes”?

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

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

end of thread, other threads:[~2020-05-01 13:54 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-04-19 12:32 [PATCH v2] iommu/qcom: Fix local_base status check Markus Elfring
2020-04-19 13:10 ` Markus Elfring
  -- strict thread matches above, loose matches on Subject: below --
2020-04-18 13:47 [PATCH v2]iommu/qcom:fix " Tang Bin
2020-04-20  4:52 ` Bjorn Andersson
2020-05-01 11:37 ` Joerg Roedel
2020-05-01 13:54   ` Tang Bin
2020-04-03 17:20 [PATCH v2] iommu/qcom: Fix " Markus Elfring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox