register_netdevice return val fix
Subsystems (2)
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
@@ -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 )
_
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_netdevicewill 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.