Skip to contentSkip to conversation

register_netdevice return val fix

PATCH Andrew Morton 2 participants 2 messages Oct 19, 2003

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

If the driver's init function returns an error code (most likely -ENODEV), register_netdevice will stomp on it and will always return -EIO.

You end up always getting an "Input/Output error" from modprobe, which is confusing.

Fix register_netdevice() to return the init function's error code, if it looks sane.

 net/core/dev.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)
net/core/dev.c renamed from net/core/dev.c~register_netdevice-retval-fix +8 -3
diff -puN net/core/dev.c~register_netdevice-retval-fix net/core/dev.c
@@ -2652,9 +2652,14 @@ int register_netdevice(struct net_device
 	dev->iflink = -1;
 
 	/* Init, if this function is available */
-	ret = -EIO;
-	if (dev->init && dev->init(dev))
-		goto out_err;
+	if (dev->init) {
+		ret = dev->init(dev);
+		if (ret) {
+			if (ret > 0)
+				ret = -EIO;
+			goto out_err;
+		}
+	}
 
 	dev->ifindex = dev_new_index();
 	if (dev->iflink == -1)

_

#1 lore raw
Quoted 8 lines · On Sat, 18 Oct 2003 19:00:14 -0700 Andrew Morton <[email protected]> wrote:

If the driver's init function returns an error code (most likely -ENODEV), register_netdevice will stomp on it and will always return -EIO.

You end up always getting an "Input/Output error" from modprobe, which is confusing.

Fix register_netdevice() to return the init function's error code, if it looks sane.

Looks fine, applied.

Thanks Andrew.