This change has been made with the goal that kernel functions should
return something more descriptive than -1 on failure.
The return value on an alloc_etherdev failure should be -ENOMEM,
and not -1.
This was found using Coccinelle. A simplified version of the semantic
patch used is:
//<smpl>
@@
expression *e;
identifier l1;
@@
e = alloc_etherdev(...);
if (e == NULL) {
...
return
- -1
+ -ENOMEM
;
}
//</smpl
Furthermore, introduced `ret` variable to store and return the
corresponding error code returned by register_netdev on failure.
The two call sites store the return value in a variable which only
checks that the value is non-zero, hence no change is required at
the call sites.
Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type,
                     int gpio, const struct wilc_hif_func *ops)
 {
-       int i;
+       int i, ret;
        struct wilc_vif *vif;
        struct net_device *ndev;
        struct wilc *wl;
        for (i = 0; i < NUM_CONCURRENT_IFC; i++) {
                ndev = alloc_etherdev(sizeof(struct wilc_vif));
                if (!ndev)
-                       return -1;
+                       return -ENOMEM;
 
                vif = netdev_priv(ndev);
                memset(vif, 0, sizeof(struct wilc_vif));
                        vif->netstats.tx_bytes = 0;
                }
 
-               if (register_netdev(ndev))
-                       return -1;
+               ret = register_netdev(ndev);
+               if (ret)
+                       return ret;
 
                vif->iftype = STATION_MODE;
                vif->mac_opened = 0;