public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mailbox: sti: fix check of error code returned by devm_ioremap_resource()
@ 2016-03-06  1:21 Vladimir Zapolskiy
  2016-03-06  3:01 ` Lee Jones
  0 siblings, 1 reply; 2+ messages in thread
From: Vladimir Zapolskiy @ 2016-03-06  1:21 UTC (permalink / raw)
  To: Jassi Brar; +Cc: Lee Jones, linux-kernel

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 <vz@mleia.com>
Fixes: 9ef4546cbd7e ("mailbox: Add support for ST's Mailbox IP")
---
 drivers/mailbox/mailbox-sti.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mailbox/mailbox-sti.c b/drivers/mailbox/mailbox-sti.c
index 2394cfe..a334db5 100644
--- a/drivers/mailbox/mailbox-sti.c
+++ b/drivers/mailbox/mailbox-sti.c
@@ -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)
-- 
2.1.4

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

end of thread, other threads:[~2016-03-06  3:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-06  1:21 [PATCH] mailbox: sti: fix check of error code returned by devm_ioremap_resource() Vladimir Zapolskiy
2016-03-06  3:01 ` Lee Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox