mailbox: sti: fix check of error code returned by devm_ioremap_resource()
PATCH 1/1 mailbox: sti: fix check of error code returned by devm_ioremap_resource()
The change fixes potential oops while accessing iomem on invalid address, if devm_ioremap_resource() fails due to some reason.
The devm_ioremap_resource() function returns ERR_PTR() and never returns NULL, which makes useless a following check for NULL.
Signed-off-by Vladimir Zapolskiy <[email protected]>
Fixes 9ef4546cbd7e ("mailbox: Add support for ST's Mailbox IP")
--- drivers/mailbox/mailbox-sti.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mailbox/mailbox-sti.c +2 -2
@@ -430,8 +430,8 @@ static int sti_mbox_probe(struct platform_device *pdev) res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); mdev->base =devm_ioremap_resource (&pdev->dev, res); -if (!mdev->base) -return -ENOMEM ; +if (IS_ERR (mdev->base)) +return PTR_ERR (mdev->base); ret =of_property_read_string (np,"mbox-name" , &mdev->name);if (ret)
Signature · 1 line
2.1.4
Quoted 11 lines · Vladimir Zapolskiy
The change fixes potential oops while accessing iomem on invalid address, if
devm_ioremap_resource()fails due to some reason.The
devm_ioremap_resource()function returnsERR_PTR()and never returns NULL, which makes useless a following check for NULL.Signed-off-by Vladimir Zapolskiy <[email protected]>Fixes 9ef4546cbd7e ("mailbox: Add support for ST's Mailbox IP")--- drivers/mailbox/mailbox-sti.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Acked-by Lee Jones <[email protected]>
Quoted 15 lines
drivers/mailbox/mailbox-sti.c +2
-2@@ -430,8 +430,8 @@ static int sti_mbox_probe(struct platform_device *pdev) res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); mdev->base =devm_ioremap_resource (&pdev->dev, res); -if (!mdev->base) -return -ENOMEM ; +if (IS_ERR (mdev->base)) +return PTR_ERR (mdev->base); ret =of_property_read_string (np,"mbox-name" , &mdev->name);if (ret)
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog