Skip to contentSkip to conversation

ipv4: Fix NULL vs error pointer check in inet_blackhole_dev_init()

PATCH Applied Dan Carpenter 4 participants 4 messages Sep 2, 2025 – Sep 4, 2025

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

PATCH 1/1 ipv4: Fix NULL vs error pointer check in inet_blackhole_dev_init()

The inetdev_init() function never returns NULL. Check for error pointers instead.

Fixes 22600596b675 ("ipv4: give an IPv4 dev to blackhole_netdev")
---
 net/ipv4/devinet.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
net/ipv4/devinet.c +3 -4
index c47d3828d4f6..942a887bf089 100644
@@ -340,14 +340,13 @@ static void inetdev_destroy(struct in_device *in_dev)
 
 static int __init inet_blackhole_dev_init(void)
 {
-	int err = 0;
+	struct in_device *in_dev;
 
 	rtnl_lock();
-	if (!inetdev_init(blackhole_netdev))
-		err = -ENOMEM;
+	in_dev = inetdev_init(blackhole_netdev);
 	rtnl_unlock();
 
-	return err;
+	return PTR_ERR_OR_ZERO(in_dev);
 }
 late_initcall(inet_blackhole_dev_init);
 
Signature · 1 line
2.47.2
#3 lore raw
In reply to Dan Carpenter
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

Quoted 8 lines · On Tue, 2 Sep 2025 09:36:08 +0300 you wrote:

The inetdev_init() function never returns NULL. Check for error pointers instead.

Fixes 22600596b675 ("ipv4: give an IPv4 dev to blackhole_netdev")
---
 net/ipv4/devinet.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

Here is the summary with links:
- [net] ipv4: Fix NULL vs error pointer check in inet_blackhole_dev_init()

    https://git.kernel.org/netdev/net/c/a51160f8da85

You are awesome, thank you!

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