Skip to contentSkip to conversation

iommu/exynos: Fix return value check in exynos_iommu_of_setup()

PATCH New weiyj_lk at 163.com 5 participants 11 messages Jul 6, 2016 – Jul 18, 2016

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iommu/exynos: Fix return value check in exynos_iommu_of_setup()

From: Wei Yongjun <[email protected]>

In case of error, the function of_platform_device_create() returns NULL pointer not ERR_PTR(). The IS_ERR() test in the return value check should be replaced with NULL test.

---
 drivers/iommu/exynos-iommu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iommu/exynos-iommu.c +2 -2
index 33dcc29..9b23059 100644
@@ -1345,8 +1345,8 @@ static int __init exynos_iommu_of_setup(struct device_node *np)
 		exynos_iommu_init();
 
 	pdev = of_platform_device_create(np, NULL, platform_bus_type.dev_root);
-	if (IS_ERR(pdev))
-		return PTR_ERR(pdev);
+	if (!pdev)
+		return -ENOMEM;
 
 	/*
 	 * use the first registered sysmmu device for performing
#1 lore raw

PATCH 1/1 iommu/exynos: Fix return value check in exynos_iommu_of_setup()

Quoted 16 lines · On Wed, Jul 06, 2016 at 12:15:54PM +0000, weiyj_lk at 163.com wrote:

From: Wei Yongjun <[email protected]>

In case of error, the function of_platform_device_create() returns NULL pointer not ERR_PTR(). The IS_ERR() test in the return value check should be replaced with NULL test.

---
 drivers/iommu/exynos-iommu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iommu/exynos-iommu.c +0 -0
index 33dcc29..9b23059 100644

drivers/iommu/exynos-iommu.c static int __init exynos_iommu_of_setup(struct device_node *np) · line 1350

Quoted 8 lines
drivers/iommu/exynos-iommu.c +2 -2
@@ -1345,8 +1345,8 @@ static int __init exynos_iommu_of_setup(struct device_node *np)
              exynos_iommu_init();
 
      pdev = of_platform_device_create(np, NULL, platform_bus_type.dev_root);
-     if (IS_ERR(pdev))
-             return PTR_ERR(pdev);
+     if (!pdev)
+             return -ENOMEM;
 

Indeed!If of_platform_device_create only returns NULL in case of failure, then IS_ERR() will be false, so

Thanks,
Dennis

Quoted 11 lines
drivers/iommu/exynos-iommu.c +0 -0
      /*
       * use the first registered sysmmu device for performing

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.

#2 lore raw

PATCH 1/1 iommu/exynos: Fix return value check in exynos_iommu_of_setup()

In reply to weiyj_lk at 163.com
Quoted 17 lines · On 07/06/2016 02:15 PM, weiyj_lk at 163.com wrote:

From: Wei Yongjun <[email protected]>

In case of error, the function of_platform_device_create() returns NULL pointer not ERR_PTR(). The IS_ERR() test in the return value check should be replaced with NULL test.

---
 drivers/iommu/exynos-iommu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iommu/exynos-iommu.c +0 -0
index 33dcc29..9b23059 100644

drivers/iommu/exynos-iommu.c static int __init exynos_iommu_of_setup(struct device_node *np) · line 1352

Quoted 10 lines
drivers/iommu/exynos-iommu.c +2 -2
@@ -1345,8 +1345,8 @@ static int __init exynos_iommu_of_setup(struct device_node *np)
 		exynos_iommu_init();
 
 	pdev = of_platform_device_create(np, NULL, platform_bus_type.dev_root);
-	if (IS_ERR(pdev))
-		return PTR_ERR(pdev);
+	if (!pdev)
+		return -ENOMEM;
 
 	/*
 	 * use the first registered sysmmu device for performing

Which in case of first sysmmu device and of_platform_device_create() failure will lead to NULL pointer exception, so I think it is appropriate to:

Fixes 8ed55c812fa8 ("iommu/exynos: Init from dt-specific callback

instead of initcall")
Cc: <[email protected]>

Best regards,
Krzysztof

#3 lore raw

PATCH 1/1 iommu/exynos: Fix return value check in exynos_iommu_of_setup()

Hi,

just a question,

Quoted 10 lines

drivers/iommu/exynos-iommu.c static int __init exynos_iommu_of_setup(struct device_node *np) · line 1352

Quoted 9 lines
drivers/iommu/exynos-iommu.c +2 -2
 	pdev = of_platform_device_create(np, NULL, platform_bus_type.dev_root);
-	if (IS_ERR(pdev))
-		return PTR_ERR(pdev);
+	if (!pdev)
+		return -ENOMEM;
 
 	/*
 	 * use the first registered sysmmu device for performing

is ENOMEM the right return value? of_platform_device_create() doesn't fail only in case of malloc failure.

Shouldn't it be ENODEV instead, which might also mean with some imagination that there is no memory available for that device?

Thanks,
Andi

Quoted 1 line
#4 lore raw

PATCH 1/1 iommu/exynos: Fix return value check in exynos_iommu_of_setup()

Hi,

Quoted 8 lines

just a question,

Quoted 6 lines
Quoted 6 lines
drivers/iommu/exynos-iommu.c +2 -2
 	pdev = of_platform_device_create(np, NULL, platform_bus_type.dev_root);
-	if (IS_ERR(pdev))
-		return PTR_ERR(pdev);
+	if (!pdev)
+		return -ENOMEM;
Quoted 9 lines
Quoted 3 lines

drivers/iommu/exynos-iommu.c static int __init exynos_iommu_of_setup(struct device_node *np) · line 1352

Quoted 3 lines
drivers/iommu/exynos-iommu.c +0 -0
 	/*
 	 * use the first registered sysmmu device for performing

is ENOMEM the right return value? of_platform_device_create() doesn't fail only in case of malloc failure.

Shouldn't it be ENODEV instead, which might also mean with some imagination that there is no memory available for that device?

Your are right, I will change the error to -ENODEV and resend the patch.

Thanks,
Wei Yongjun

maintainer
#5 lore raw

PATCH 1/1 iommu/exynos: Fix return value check in exynos_iommu_of_setup()

In reply to Krzysztof Kozlowski

Hello,

Quoted 31 lines · Krzysztof Kozlowski
Quoted 17 lines · On 07/06/2016 02:15 PM, weiyj_lk at 163.com wrote:

From: Wei Yongjun <[email protected]>

In case of error, the function of_platform_device_create() returns NULL pointer not ERR_PTR(). The IS_ERR() test in the return value check should be replaced with NULL test.

---
  drivers/iommu/exynos-iommu.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iommu/exynos-iommu.c +0 -0
index 33dcc29..9b23059 100644

drivers/iommu/exynos-iommu.c static int __init exynos_iommu_of_setup(struct device_node *np) · line 1352

Quoted 10 lines
drivers/iommu/exynos-iommu.c +2 -2
@@ -1345,8 +1345,8 @@ static int __init exynos_iommu_of_setup(struct device_node *np)
  		exynos_iommu_init();
 
  	pdev = of_platform_device_create(np, NULL, platform_bus_type.dev_root);
-	if (IS_ERR(pdev))
-		return PTR_ERR(pdev);
+	if (!pdev)
+		return -ENOMEM;
 
  	/*
  	 * use the first registered sysmmu device for performing
Quoted 6 lines

Which in case of first sysmmu device and of_platform_device_create() failure will lead to NULL pointer exception, so I think it is appropriate to:

Fixes 8ed55c812fa8 ("iommu/exynos: Init from dt-specific callback

instead of initcall")
Cc: <[email protected]>

Thanks for spotting this issue.

Best regards

Signature · 2 lines
Marek Szyprowski, PhD
Samsung R&D Institute Poland
#6 lore raw

PATCH v2 1/1 iommu/exynos: Fix return value check in exynos_iommu_of_setup()

In reply to weiyj_lk at 163.com

From: Wei Yongjun <[email protected]>

In case of error, the function of_platform_device_create() returns NULL pointer not ERR_PTR(). The IS_ERR() test in the return value check should be replaced with NULL test.

---
v1 -> v2: chenge the error code to -ENODEV

---
 drivers/iommu/exynos-iommu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iommu/exynos-iommu.c +2 -2
index 33dcc29..9b23059 100644
@@ -1345,8 +1345,8 @@ static int __init exynos_iommu_of_setup(struct device_node *np)
 		exynos_iommu_init();
 
 	pdev = of_platform_device_create(np, NULL, platform_bus_type.dev_root);
-	if (IS_ERR(pdev))
-		return PTR_ERR(pdev);
+	if (!pdev)
+		return -ENODEV;
 
 	/*
 	 * use the first registered sysmmu device for performing
#7 lore raw

PATCH v2 1/1 iommu/exynos: Fix return value check in exynos_iommu_of_setup()

Hi Wei,

Quoted 7 lines · On Thu, Jul 07, 2016 at 02:59:32AM +0000, weiyj_lk at 163.com wrote:

From: Wei Yongjun <[email protected]>

In case of error, the function of_platform_device_create() returns NULL pointer not ERR_PTR(). The IS_ERR() test in the return value check should be replaced with NULL test.

Thanks,
Andi

Quoted 28 lines

---
v1 -> v2: chenge the error code to -ENODEV

---
 drivers/iommu/exynos-iommu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iommu/exynos-iommu.c +2 -3
index 33dcc29..9b23059 100644
@@ -1345,8 +1345,8 @@ static int __init exynos_iommu_of_setup(struct device_node *np)
 		exynos_iommu_init();
 
 	pdev = of_platform_device_create(np, NULL, platform_bus_type.dev_root);
-	if (IS_ERR(pdev))
-		return PTR_ERR(pdev);
+	if (!pdev)
+		return -ENODEV;
 
 	/*
 	 * use the first registered sysmmu device for performing
 
 
--

To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

#8 lore raw

PATCH v2 1/1 iommu/exynos: Fix return value check in exynos_iommu_of_setup()

In reply to weiyj_lk at 163.com
Quoted 6 lines · On 07/07/2016 04:59 AM, weiyj_lk at 163.com wrote:

From: Wei Yongjun <[email protected]>

In case of error, the function of_platform_device_create() returns NULL pointer not ERR_PTR(). The IS_ERR() test in the return value check should be replaced with NULL test.

Quoted 7 lines

---
v1 -> v2: chenge the error code to -ENODEV

---
 drivers/iommu/exynos-iommu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Why you didn't include mine and Dennis reviews? Why you ignored my comments - you don't agree with them?

Best regards,
Krzysztof

#9 lore raw

PATCH v2 1/1 iommu/exynos: Fix return value check in exynos_iommu_of_setup()

Quoted 14 lines · Krzysztof Kozlowski
Quoted 6 lines · On 07/07/2016 04:59 AM, weiyj_lk at 163.com wrote:

From: Wei Yongjun <[email protected]>

In case of error, the function of_platform_device_create() returns NULL pointer not ERR_PTR(). The IS_ERR() test in the return value check should be replaced with NULL test.

Quoted 7 lines

---
v1 -> v2: chenge the error code to -ENODEV

---
  drivers/iommu/exynos-iommu.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 3 lines

Why you didn't include mine and Dennis reviews? Why you ignored my comments - you don't agree with them?

Sorry, I missed your last mail. I will change patch as your advise.

Regards,
Yongjun Wei

#10 lore raw

PATCH v3 1/1 iommu/exynos: Fix return value check in exynos_iommu_of_setup()

In reply to weiyj_lk at 163.com

From: Wei Yongjun <[email protected]>

In case of error, the function of_platform_device_create() returns NULL pointer not ERR_PTR(). The IS_ERR() test in the return value check should be replaced with NULL test.

Fixes 8ed55c812fa8 ("iommu/exynos: Init from dt-specific callback

instead of initcall")

---
v2 -> v3: added fixes and Reviewed-by.

---
 drivers/iommu/exynos-iommu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iommu/exynos-iommu.c +2 -2
index 33dcc29..9b23059 100644
@@ -1345,8 +1345,8 @@ static int __init exynos_iommu_of_setup(struct device_node *np)
 		exynos_iommu_init();
 
 	pdev = of_platform_device_create(np, NULL, platform_bus_type.dev_root);
-	if (IS_ERR(pdev))
-		return PTR_ERR(pdev);
+	if (!pdev)
+		return -ENODEV;
 
 	/*
 	 * use the first registered sysmmu device for performing