linux-watchdog.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next] watchdog: wdat_wdt: fix return value check in wdat_wdt_probe()
@ 2016-09-28 14:51 Wei Yongjun
  2016-09-28 14:59 ` Mika Westerberg
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Wei Yongjun @ 2016-09-28 14:51 UTC (permalink / raw)
  To: Wim Van Sebroeck, Guenter Roeck, Mika Westerberg,
	Rafael J. Wysocki
  Cc: Wei Yongjun, linux-watchdog

From: Wei Yongjun <weiyongjun1@huawei.com>

In case of error, the function devm_ioremap_resource() returns ERR_PTR()
and never returns NULL. The NULL test in the return value check should
be replaced with IS_ERR().

Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
---
 drivers/watchdog/wdat_wdt.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/watchdog/wdat_wdt.c b/drivers/watchdog/wdat_wdt.c
index 6b64645..4594723 100644
--- a/drivers/watchdog/wdat_wdt.c
+++ b/drivers/watchdog/wdat_wdt.c
@@ -351,16 +351,17 @@ static int wdat_wdt_probe(struct platform_device *pdev)
 		res = &pdev->resource[i];
 		if (resource_type(res) == IORESOURCE_MEM) {
 			reg = devm_ioremap_resource(&pdev->dev, res);
+			if (IS_ERR(reg))
+				return PTR_ERR(reg);
 		} else if (resource_type(res) == IORESOURCE_IO) {
 			reg = devm_ioport_map(&pdev->dev, res->start, 1);
+			if (!reg)
+				return -ENOMEM;
 		} else {
 			dev_err(&pdev->dev, "Unsupported resource\n");
 			return -EINVAL;
 		}
 
-		if (!reg)
-			return -ENOMEM;
-
 		regs[i] = reg;
 	}

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

end of thread, other threads:[~2016-09-28 21:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-28 14:51 [PATCH -next] watchdog: wdat_wdt: fix return value check in wdat_wdt_probe() Wei Yongjun
2016-09-28 14:59 ` Mika Westerberg
2016-09-28 21:50   ` Rafael J. Wysocki
2016-09-28 15:52 ` Guenter Roeck
2016-09-28 16:27 ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).