Commit 0cc053dd authored by Sergio Paracuellos's avatar Sergio Paracuellos Committed by Greg Kroah-Hartman

staging: ks7010: fix error paths in ks7010_sdio_remove function

This commit reviews and fixes error paths in ks7010_sdio_remove
driver function. It change logic to handle error directly
after priv dereference to avoid one level indentation. It also
removes a temporal netdev variable which wasn't being used in all
of the function calls. Also if send_stop_request call fails it
was making a direct 'return' instead of doing a properly cleaning.
Because of this a new 'err_free_card' label has been added.
Signed-off-by: default avatarSergio Paracuellos <sergio.paracuellos@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 31d7b1b1
...@@ -1112,10 +1112,10 @@ static void ks7010_sdio_remove(struct sdio_func *func) ...@@ -1112,10 +1112,10 @@ static void ks7010_sdio_remove(struct sdio_func *func)
return; return;
priv = card->priv; priv = card->priv;
if (priv) { if (!priv)
struct net_device *netdev = priv->net_dev; goto err_free_card;
ks_wlan_net_stop(netdev); ks_wlan_net_stop(priv->net_dev);
/* interrupt disable */ /* interrupt disable */
sdio_claim_host(func); sdio_claim_host(func);
...@@ -1125,7 +1125,7 @@ static void ks7010_sdio_remove(struct sdio_func *func) ...@@ -1125,7 +1125,7 @@ static void ks7010_sdio_remove(struct sdio_func *func)
ret = send_stop_request(func); ret = send_stop_request(func);
if (ret) /* memory allocation failure */ if (ret) /* memory allocation failure */
return; goto err_free_card;
if (priv->wq) { if (priv->wq) {
flush_workqueue(priv->wq); flush_workqueue(priv->wq);
...@@ -1134,17 +1134,17 @@ static void ks7010_sdio_remove(struct sdio_func *func) ...@@ -1134,17 +1134,17 @@ static void ks7010_sdio_remove(struct sdio_func *func)
hostif_exit(priv); hostif_exit(priv);
unregister_netdev(netdev); unregister_netdev(priv->net_dev);
trx_device_exit(priv); trx_device_exit(priv);
free_netdev(priv->net_dev); free_netdev(priv->net_dev);
card->priv = NULL; card->priv = NULL;
}
sdio_claim_host(func); sdio_claim_host(func);
sdio_release_irq(func); sdio_release_irq(func);
sdio_disable_func(func); sdio_disable_func(func);
sdio_release_host(func); sdio_release_host(func);
err_free_card:
sdio_set_drvdata(func, NULL); sdio_set_drvdata(func, NULL);
kfree(card); kfree(card);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment