diff mbox series

[net-next,2/3] net: sparx5: fix return value check in sparx5_create_targets()

Message ID 20210626044420.390517-3-yangyingliang@huawei.com (mailing list archive)
State Accepted
Commit 8f4c38f7588650690ffa08f7784c831e0a8c38e7
Delegated to: Netdev Maintainers
Headers show
Series fix some bugs for sparx5 | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for net-next
netdev/subject_prefix success Link
netdev/cc_maintainers fail 2 blamed authors not CCed: p.zabel@pengutronix.de bjarni.jonasson@microchip.com; 4 maintainers not CCed: linux-arm-kernel@lists.infradead.org UNGLinuxDriver@microchip.com p.zabel@pengutronix.de bjarni.jonasson@microchip.com
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 12 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success Link

Commit Message

Yang Yingliang June 26, 2021, 4:44 a.m. UTC
In case of error, the function devm_ioremap() returns NULL pointer
not ERR_PTR(). The IS_ERR() test in the return value check should
be replaced with NULL test.

Fixes: 3cfa11bac9bb ("net: sparx5: add the basic sparx5 driver")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 drivers/net/ethernet/microchip/sparx5/sparx5_main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_main.c b/drivers/net/ethernet/microchip/sparx5/sparx5_main.c
index 665e20ccb404..abaa086ce345 100644
--- a/drivers/net/ethernet/microchip/sparx5/sparx5_main.c
+++ b/drivers/net/ethernet/microchip/sparx5/sparx5_main.c
@@ -236,10 +236,10 @@  static int sparx5_create_targets(struct sparx5 *sparx5)
 					  iores[idx]->start,
 					  iores[idx]->end - iores[idx]->start
 					  + 1);
-		if (IS_ERR(iomem[idx])) {
+		if (!iomem[idx]) {
 			dev_err(sparx5->dev, "Unable to get switch registers: %s\n",
 				iores[idx]->name);
-			return PTR_ERR(iomem[idx]);
+			return -ENOMEM;
 		}
 		begin[idx] = iomem[idx] - sparx5_main_iomap[range_id[idx]].offset;
 	}