iommu/exynos: Fix return value check in exynos_iommu_of_setup()
Subsystems (4)
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
@@ -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
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 notERR_PTR(). TheIS_ERR()test in the return value check should be replaced with NULL test.Signed-off-by Wei Yongjun <[email protected]>--- drivers/iommu/exynos-iommu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/iommu/exynos-iommu.c +0
-0
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.
PATCH 1/1 iommu/exynos: Fix return value check in exynos_iommu_of_setup()
In reply to weiyj_lk at 163.comQuoted 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 notERR_PTR(). TheIS_ERR()test in the return value check should be replaced with NULL test.Signed-off-by Wei Yongjun <[email protected]>--- drivers/iommu/exynos-iommu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/iommu/exynos-iommu.c +0
-0
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:
instead of initcall")
Cc: <[email protected]>
Best regards,
Krzysztof
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
-2pdev =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
Reviewed-by Krzysztof Kozlowski <[email protected]>
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
-2pdev =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
Marek Szyprowski
maintainerPATCH 1/1 iommu/exynos: Fix return value check in exynos_iommu_of_setup()
In reply to Krzysztof KozlowskiHello,
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 notERR_PTR(). TheIS_ERR()test in the return value check should be replaced with NULL test.Signed-off-by Wei Yongjun <[email protected]>--- drivers/iommu/exynos-iommu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/iommu/exynos-iommu.c +0
-0drivers/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 Reviewed-by Krzysztof Kozlowski <[email protected]>
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 callbackinstead of initcall")
Cc: <[email protected]>
Thanks for spotting this issue.
Best regards
Signature · 2 lines
Marek Szyprowski, PhD Samsung R&D Institute Poland
PATCH v2 1/1 iommu/exynos: Fix return value check in exynos_iommu_of_setup()
In reply to weiyj_lk at 163.comFrom: 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
@@ -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
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 notERR_PTR(). TheIS_ERR()test in the return value check should be replaced with NULL test.Signed-off-by Wei Yongjun <[email protected]>
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@@ -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
PATCH v2 1/1 iommu/exynos: Fix return value check in exynos_iommu_of_setup()
In reply to weiyj_lk at 163.comQuoted 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 notERR_PTR(). TheIS_ERR()test in the return value check should be replaced with NULL test.
Quoted 7 lines
Signed-off-by Wei Yongjun <[email protected]>---
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
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 notERR_PTR(). TheIS_ERR()test in the return value check should be replaced with NULL test.Quoted 7 lines
Signed-off-by Wei Yongjun <[email protected]>---
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
PATCH v3 1/1 iommu/exynos: Fix return value check in exynos_iommu_of_setup()
In reply to weiyj_lk at 163.comFrom: 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.
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
@@ -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