bus: fsl-mc: Check return value of platform_get_resource()
PATCH v2 1/1 bus: fsl-mc: Check return value of platform_get_resource()
platform_get_resource() returns NULL in case of failure, so check its return value and propagate the error in order to prevent NULL pointer dereference.
---
Changes in v2:
- Add Fixes and Cc tags, as suggested by Markus Elfring and Christophe Leroy.
- Remove blank line before the if statement, as suggested by Markus Elfring.
- Replace ENODEV with EINVAL, as suggestd by Christophe Leroy.
drivers/bus/fsl-mc/fsl-mc-bus.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/bus/fsl-mc/fsl-mc-bus.c +3 -0
@@ -1105,6 +1105,9 @@ static int fsl_mc_bus_probe(struct platform_device *pdev)* Get physical address of MC portal for the root DPRC: */ plat_res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); +if (!plat_res) +return -EINVAL ; + mc_portal_phys_addr = plat_res->start; mc_portal_size =resource_size (plat_res); mc_portal_base_phys_addr = mc_portal_phys_addr & ~0x3ffffff ;
Signature · 1 line
2.43.0
Quoted 7 lines · Salah Triki
platform_get_resource()returns NULL in case of failure, so check its return value and propagate the error in order to prevent NULL pointer dereference.Fixes 6305166c8771 ("bus: fsl-mc: Add ACPI support for fsl-mc")Cc <[email protected]>Signed-off-by Salah Triki <[email protected]>
Quoted 28 lines
---
Changes in v2:
- Add Fixes and Cc tags, as suggested by Markus Elfring and Christophe Leroy.
- Remove blank line before the if statement, as suggested by Markus Elfring.
- Replace ENODEV with EINVAL, as suggestd by Christophe Leroy.drivers/bus/fsl-mc/fsl-mc-bus.c | 3 +++ 1 file changed, 3 insertions(+)drivers/bus/fsl-mc/fsl-mc-bus.c +3
-0@@ -1105,6 +1105,9 @@ static int fsl_mc_bus_probe(struct platform_device *pdev)* Get physical address of MC portal for the root DPRC: */ plat_res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); +if (!plat_res) +return -EINVAL ; + mc_portal_phys_addr = plat_res->start; mc_portal_size =resource_size (plat_res); mc_portal_base_phys_addr = mc_portal_phys_addr & ~0x3ffffff ;Signature · 1 line
2.43.0
Christophe Leroy
AppliedLe 25/08/2025 à 11:34, Salah Triki a écrit :
Quoted 35 lines
[Vous ne recevez pas souvent de courriers de [email protected]. D?couvrez pourquoi ceci est important ? https://aka.ms/LearnAboutSenderIdentification ]
platform_get_resource()returns NULL in case of failure, so check its return value and propagate the error in order to prevent NULL pointer dereference.Fixes 6305166c8771 ("bus: fsl-mc: Add ACPI support for fsl-mc")Cc <[email protected]>Signed-off-by Salah Triki <[email protected]>---
Changes in v2:
- Add Fixes and Cc tags, as suggested by Markus Elfring and Christophe Leroy.
- Remove blank line before the if statement, as suggested by Markus Elfring.
- Replace ENODEV with EINVAL, as suggestd by Christophe Leroy.drivers/bus/fsl-mc/fsl-mc-bus.c | 3 +++ 1 file changed, 3 insertions(+)drivers/bus/fsl-mc/fsl-mc-bus.c +3
-1@@ -1105,6 +1105,9 @@ static int fsl_mc_bus_probe(struct platform_device *pdev)* Get physical address of MC portal for the root DPRC: */ plat_res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); +if (!plat_res) +return -EINVAL ; + mc_portal_phys_addr = plat_res->start; mc_portal_size =resource_size (plat_res); mc_portal_base_phys_addr = mc_portal_phys_addr & ~0x3ffffff ; --
Quoted 2 lines
2.43.0
Applied, thanks!
Christophe