summaryrefslogtreecommitdiffstats
path: root/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
diff options
context:
space:
mode:
authorAjay Singh <ajay.kathat@microchip.com>2018-09-04 12:09:41 +0530
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-09-10 18:06:51 +0200
commita53b0b1392a1bf11d21bac3e13f543ee90923ed6 (patch)
tree4a741f307bd99b30a586ae7a6ff68e6deb43cb75 /drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
parentb3ee105c332efc49199e138822923be3562619aa (diff)
staging: wilc1000: refactor wilc_netdev_init() to handle memory free in error path
Refactor the wilc_netdev_init() to cleanup the memory for error scenario and remove unnecessary 'dev' pointer check. Signed-off-by: Ajay Singh <ajay.kathat@microchip.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/wilc1000/wilc_wfi_cfgoperations.c')
-rw-r--r--drivers/staging/wilc1000/wilc_wfi_cfgoperations.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
index d103dce223bc..37c26d465bcf 100644
--- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
+++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
@@ -2145,8 +2145,12 @@ struct wireless_dev *wilc_create_wiphy(struct net_device *net,
set_wiphy_dev(wdev->wiphy, dev);
ret = wiphy_register(wdev->wiphy);
- if (ret)
+ if (ret) {
netdev_err(net, "Cannot register wiphy device\n");
+ wiphy_free(wdev->wiphy);
+ kfree(wdev);
+ return NULL;
+ }
priv->dev = net;
return wdev;