netdev
[Top] [All Lists]

register_netdevice return val fix

To: "David S. Miller" <davem@xxxxxxxxxx>
Subject: register_netdevice return val fix
From: Andrew Morton <akpm@xxxxxxxx>
Date: Sat, 18 Oct 2003 19:00:14 -0700
Cc: netdev@xxxxxxxxxxx
Sender: netdev-bounce@xxxxxxxxxxx

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(-)

diff -puN net/core/dev.c~register_netdevice-retval-fix net/core/dev.c
--- 25/net/core/dev.c~register_netdevice-retval-fix     2003-10-18 
18:50:52.000000000 -0700
+++ 25-akpm/net/core/dev.c      2003-10-18 18:51:39.000000000 -0700
@@ -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)

_


<Prev in Thread] Current Thread [Next in Thread>