Skip to contentSkip to conversation

net: lan966x: fix a IS_ERR() vs NULL check in lan966x_create_targets()

PATCH Applied Dan Carpenter 3 participants 3 messages Dec 3, 2021

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: lan966x: fix a IS_ERR() vs NULL check in lan966x_create_targets()

The devm_ioremap() function does not return error pointers. It returns NULL.

Fixes db8bcaad5393 ("net: lan966x: add the basic lan966x driver")
---
 drivers/net/ethernet/microchip/lan966x/lan966x_main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/microchip/lan966x/lan966x_main.c +2 -2
index e9e4dca6542d..00930d81521a 100644
@@ -83,10 +83,10 @@ static int lan966x_create_targets(struct platform_device *pdev,
 		begin[idx] = devm_ioremap(&pdev->dev,
 					  iores[idx]->start,
 					  resource_size(iores[idx]));
-		if (IS_ERR(begin[idx])) {
+		if (!begin[idx]) {
 			dev_err(&pdev->dev, "Unable to get registers: %s\n",
 				iores[idx]->name);
-			return PTR_ERR(begin[idx]);
+			return -ENOMEM;
 		}
 	}
 
Signature · 1 line
2.20.1
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 3 lines · Dan Carpenter

The devm_ioremap() function does not return error pointers. It returns NULL.

Quoted 27 lines
Fixes db8bcaad5393 ("net: lan966x: add the basic lan966x driver")
---
 drivers/net/ethernet/microchip/lan966x/lan966x_main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/microchip/lan966x/lan966x_main.c +2 -3
index e9e4dca6542d..00930d81521a 100644
@@ -83,10 +83,10 @@ static int lan966x_create_targets(struct platform_device *pdev,
                begin[idx] = devm_ioremap(&pdev->dev,
                                          iores[idx]->start,
                                          resource_size(iores[idx]));
-               if (IS_ERR(begin[idx])) {
+               if (!begin[idx]) {
                        dev_err(&pdev->dev, "Unable to get registers: %s\n",
                                iores[idx]->name);
-                       return PTR_ERR(begin[idx]);
+                       return -ENOMEM;
                }
        }
 
--

2.20.1

Signature · 1 line
/Horatiu
#2 lore raw
In reply to Dan Carpenter
This patch was applied to netdev/net-next.git (master) by David S. Miller <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (master) by David S. Miller <[email protected]>:

Quoted 8 lines · On Fri, 3 Dec 2021 12:55:31 +0300 you wrote:

The devm_ioremap() function does not return error pointers. It returns NULL.

Fixes db8bcaad5393 ("net: lan966x: add the basic lan966x driver")
---
 drivers/net/ethernet/microchip/lan966x/lan966x_main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Here is the summary with links:
- [net-next] net: lan966x: fix a IS_ERR() vs NULL check in lan966x_create_targets()

    https://git.kernel.org/netdev/net-next/c/bb14bfc7eb92

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html