linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2]iommu/qcom:fix local_base status check
@ 2020-04-02  6:03 Tang Bin
  2020-04-02  6:15 ` Bjorn Andersson
  0 siblings, 1 reply; 11+ messages in thread
From: Tang Bin @ 2020-04-02  6:03 UTC (permalink / raw)
  To: robdclark, agross, bjorn.andersson
  Cc: joro, linux-arm-msm, linux-kernel, Tang Bin

------v2-----------------
As requested, add some {} around this chunk.

------v1-----------------
Release resources when exiting on error.

Signed-off-by: Tang Bin <tangbin@cmss.chinamobile.com>
---
 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..c08aa9651 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




^ permalink raw reply related	[flat|nested] 11+ messages in thread
* Re: [PATCH v2] iommu/qcom: Fix local_base status check
@ 2020-04-03 17:20 Markus Elfring
  0 siblings, 0 replies; 11+ 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: linux-kernel, kernel-janitors

> 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

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

> > ------v2-----------------
> > As requested, add some {} around this chunk.
> >
> > ------v1-----------------
>
> The changelog typically goes after the ---, as it doesn't add value to
> the resulting git log. So please drop the above 4 lines from the commit
> message. And please use ./scripts/get_maintainer.pl to find your
> recipient list.
>
> Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>

How does this tag fit to the requested changes?

Regards,
Markus

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

> > ------v2-----------------
> > As requested, add some {} around this chunk.
> >
> > ------v1-----------------
>
> The changelog typically goes after the ---, as it doesn't add value to
> the resulting git log. So please drop the above 4 lines from the commit
> message. And please use ./scripts/get_maintainer.pl to find your
> recipient list.
>
> Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>

How does this tag fit to the requested changes?

Regards,
Markus

^ permalink raw reply	[flat|nested] 11+ 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; 11+ 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




^ permalink raw reply related	[flat|nested] 11+ messages in thread
* 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; 11+ 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: linux-kernel, kernel-janitors

> 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

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

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

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-02  6:03 [PATCH v2]iommu/qcom:fix local_base status check Tang Bin
2020-04-02  6:15 ` Bjorn Andersson
2020-04-03 17:20 [PATCH v2] iommu/qcom: Fix " Markus Elfring
2020-04-03 17:45 Markus Elfring
2020-04-03 17:45 Markus Elfring
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-19 12:32 [PATCH v2] iommu/qcom: Fix " Markus Elfring
2020-04-19 13:10 ` 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).