Commit 45028223 authored by Igor Mitsyanko's avatar Igor Mitsyanko Committed by Kalle Valo

qtnfmac: remove VIF in firmware in case of error

Currently in case of error when registering network device with the
kernel, we won't properly cleanup VIF state in firmware due to DEL_VIF
command will not be send to wifi card. Make sure it does.
Signed-off-by: default avatarIgor Mitsyanko <igor.mitsyanko.os@quantenna.com>
Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
parent 4c8c0d8f
...@@ -238,22 +238,20 @@ static struct wireless_dev *qtnf_add_virtual_intf(struct wiphy *wiphy, ...@@ -238,22 +238,20 @@ static struct wireless_dev *qtnf_add_virtual_intf(struct wiphy *wiphy,
pr_err("VIF%u.%u: FW reported bad MAC: %pM\n", pr_err("VIF%u.%u: FW reported bad MAC: %pM\n",
mac->macid, vif->vifid, vif->mac_addr); mac->macid, vif->vifid, vif->mac_addr);
ret = -EINVAL; ret = -EINVAL;
goto err_mac; goto error_del_vif;
} }
ret = qtnf_core_net_attach(mac, vif, name, name_assign_t); ret = qtnf_core_net_attach(mac, vif, name, name_assign_t);
if (ret) { if (ret) {
pr_err("VIF%u.%u: failed to attach netdev\n", mac->macid, pr_err("VIF%u.%u: failed to attach netdev\n", mac->macid,
vif->vifid); vif->vifid);
goto err_net; goto error_del_vif;
} }
vif->wdev.netdev = vif->netdev; vif->wdev.netdev = vif->netdev;
return &vif->wdev; return &vif->wdev;
err_net: error_del_vif:
vif->netdev = NULL;
err_mac:
qtnf_cmd_send_del_intf(vif); qtnf_cmd_send_del_intf(vif);
err_cmd: err_cmd:
vif->wdev.iftype = NL80211_IFTYPE_UNSPECIFIED; vif->wdev.iftype = NL80211_IFTYPE_UNSPECIFIED;
......
...@@ -465,10 +465,8 @@ int qtnf_core_net_attach(struct qtnf_wmac *mac, struct qtnf_vif *vif, ...@@ -465,10 +465,8 @@ int qtnf_core_net_attach(struct qtnf_wmac *mac, struct qtnf_vif *vif,
dev = alloc_netdev_mqs(sizeof(struct qtnf_vif *), name, dev = alloc_netdev_mqs(sizeof(struct qtnf_vif *), name,
name_assign_type, ether_setup, 1, 1); name_assign_type, ether_setup, 1, 1);
if (!dev) { if (!dev)
vif->wdev.iftype = NL80211_IFTYPE_UNSPECIFIED;
return -ENOMEM; return -ENOMEM;
}
vif->netdev = dev; vif->netdev = dev;
...@@ -491,7 +489,7 @@ int qtnf_core_net_attach(struct qtnf_wmac *mac, struct qtnf_vif *vif, ...@@ -491,7 +489,7 @@ int qtnf_core_net_attach(struct qtnf_wmac *mac, struct qtnf_vif *vif,
ret = register_netdevice(dev); ret = register_netdevice(dev);
if (ret) { if (ret) {
free_netdev(dev); free_netdev(dev);
vif->wdev.iftype = NL80211_IFTYPE_UNSPECIFIED; vif->netdev = NULL;
} }
return ret; return ret;
...@@ -588,19 +586,19 @@ static int qtnf_core_mac_attach(struct qtnf_bus *bus, unsigned int macid) ...@@ -588,19 +586,19 @@ static int qtnf_core_mac_attach(struct qtnf_bus *bus, unsigned int macid)
ret = qtnf_cmd_send_get_phy_params(mac); ret = qtnf_cmd_send_get_phy_params(mac);
if (ret) { if (ret) {
pr_err("MAC%u: failed to get PHY settings\n", macid); pr_err("MAC%u: failed to get PHY settings\n", macid);
goto error; goto error_del_vif;
} }
ret = qtnf_mac_init_bands(mac); ret = qtnf_mac_init_bands(mac);
if (ret) { if (ret) {
pr_err("MAC%u: failed to init bands\n", macid); pr_err("MAC%u: failed to init bands\n", macid);
goto error; goto error_del_vif;
} }
ret = qtnf_wiphy_register(&bus->hw_info, mac); ret = qtnf_wiphy_register(&bus->hw_info, mac);
if (ret) { if (ret) {
pr_err("MAC%u: wiphy registration failed\n", macid); pr_err("MAC%u: wiphy registration failed\n", macid);
goto error; goto error_del_vif;
} }
mac->wiphy_registered = 1; mac->wiphy_registered = 1;
...@@ -612,15 +610,16 @@ static int qtnf_core_mac_attach(struct qtnf_bus *bus, unsigned int macid) ...@@ -612,15 +610,16 @@ static int qtnf_core_mac_attach(struct qtnf_bus *bus, unsigned int macid)
if (ret) { if (ret) {
pr_err("MAC%u: failed to attach netdev\n", macid); pr_err("MAC%u: failed to attach netdev\n", macid);
vif->wdev.iftype = NL80211_IFTYPE_UNSPECIFIED; goto error_del_vif;
vif->netdev = NULL;
goto error;
} }
pr_debug("MAC%u initialized\n", macid); pr_debug("MAC%u initialized\n", macid);
return 0; return 0;
error_del_vif:
qtnf_cmd_send_del_intf(vif);
vif->wdev.iftype = NL80211_IFTYPE_UNSPECIFIED;
error: error:
qtnf_core_mac_detach(bus, macid); qtnf_core_mac_detach(bus, macid);
return ret; return ret;
......
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