From fe747f0f34c638b639e1158f62c5d2f7a6d589c9 Mon Sep 17 00:00:00 2001 From: Amitoj Kaur Chawla Date: Wed, 17 Feb 2016 20:41:03 +0530 Subject: [PATCH] staging: wilc1000: Return correct error codes 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: // @@ expression *e; identifier l1; @@ e = alloc_etherdev(...); if (e == NULL) { ... return - -1 + -ENOMEM ; } // Reviewed-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/linux_wlan.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c index a731b46f9d13..274f468ef8eb 100644 --- a/drivers/staging/wilc1000/linux_wlan.c +++ b/drivers/staging/wilc1000/linux_wlan.c @@ -1312,7 +1312,7 @@ EXPORT_SYMBOL_GPL(wilc_netdev_cleanup); 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; @@ -1333,7 +1333,7 @@ int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type, 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)); @@ -1372,8 +1372,9 @@ int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type, 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; -- 2.39.5