All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: sgi: ioc3-eth: Fix return value check in ioc3eth_probe()
@ 2020-05-20  9:55 Tang Bin
  2020-05-22  0:27 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Tang Bin @ 2020-05-20  9:55 UTC (permalink / raw)
  To: davem, ralf, paulburton, tbogendoerfer
  Cc: linux-mips, netdev, linux-kernel, Tang Bin, Zhang Shengju

In the function devm_platform_ioremap_resource(), if get resource
failed, the return value is ERR_PTR() not NULL. Thus it must be
replaced by IS_ERR(), or else it may result in crashes if a critical
error path is encountered.

Fixes: 0ce5ebd24d25 ("mfd: ioc3: Add driver for SGI IOC3 chip")
Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
Signed-off-by: Tang Bin <tangbin@cmss.chinamobile.com>
---
 drivers/net/ethernet/sgi/ioc3-eth.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/sgi/ioc3-eth.c b/drivers/net/ethernet/sgi/ioc3-eth.c
index db6b2988e..8021a3d34 100644
--- a/drivers/net/ethernet/sgi/ioc3-eth.c
+++ b/drivers/net/ethernet/sgi/ioc3-eth.c
@@ -865,17 +865,17 @@ static int ioc3eth_probe(struct platform_device *pdev)
 	ip = netdev_priv(dev);
 	ip->dma_dev = pdev->dev.parent;
 	ip->regs = devm_platform_ioremap_resource(pdev, 0);
-	if (!ip->regs) {
-		err = -ENOMEM;
+	if (IS_ERR(ip->regs)) {
+		err = PTR_ERR(ip->regs);
 		goto out_free;
 	}
 
 	ip->ssram = devm_platform_ioremap_resource(pdev, 1);
-	if (!ip->ssram) {
-		err = -ENOMEM;
+	if (IS_ERR(ip->ssram)) {
+		err = PTR_ERR(ip->ssram);
 		goto out_free;
 	}
-
+
 	dev->irq = platform_get_irq(pdev, 0);
 	if (dev->irq < 0) {
 		err = dev->irq;
-- 
2.20.1.windows.1




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

* Re: [PATCH] net: sgi: ioc3-eth: Fix return value check in ioc3eth_probe()
  2020-05-20  9:55 [PATCH] net: sgi: ioc3-eth: Fix return value check in ioc3eth_probe() Tang Bin
@ 2020-05-22  0:27 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2020-05-22  0:27 UTC (permalink / raw)
  To: tangbin
  Cc: ralf, paulburton, tbogendoerfer, linux-mips, netdev,
	linux-kernel, zhangshengju

From: Tang Bin <tangbin@cmss.chinamobile.com>
Date: Wed, 20 May 2020 17:55:32 +0800

> In the function devm_platform_ioremap_resource(), if get resource
> failed, the return value is ERR_PTR() not NULL. Thus it must be
> replaced by IS_ERR(), or else it may result in crashes if a critical
> error path is encountered.
> 
> Fixes: 0ce5ebd24d25 ("mfd: ioc3: Add driver for SGI IOC3 chip")
> Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
> Signed-off-by: Tang Bin <tangbin@cmss.chinamobile.com>

Applied, thanks.

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

end of thread, other threads:[~2020-05-22  0:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-20  9:55 [PATCH] net: sgi: ioc3-eth: Fix return value check in ioc3eth_probe() Tang Bin
2020-05-22  0:27 ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.