p54 stores the vif and changes its operating mode before validating the interface type and before p54_setup_mac() can fail. Since mac80211 does not call remove_interface after a failed add, either path can leave the driver believing that an interface remains active. Publish the vif only after type validation and restore the monitor state when MAC setup fails. Fixes: 1ed32e4fc8cf ("mac80211: remove struct ieee80211_if_init_conf") Signed-off-by: Jiale Yao --- drivers/net/wireless/intersil/p54/main.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/intersil/p54/main.c b/drivers/net/wireless/intersil/p54/main.c index 57a62108cbc3..69d85efb9260 100644 --- a/drivers/net/wireless/intersil/p54/main.c +++ b/drivers/net/wireless/intersil/p54/main.c @@ -236,8 +236,6 @@ static int p54_add_interface(struct ieee80211_hw *dev, return -EOPNOTSUPP; } - priv->vif = vif; - switch (vif->type) { case NL80211_IFTYPE_STATION: case NL80211_IFTYPE_ADHOC: @@ -250,8 +248,14 @@ static int p54_add_interface(struct ieee80211_hw *dev, return -EOPNOTSUPP; } + priv->vif = vif; memcpy(priv->mac_addr, vif->addr, ETH_ALEN); err = p54_setup_mac(priv); + if (err) { + priv->vif = NULL; + priv->mode = NL80211_IFTYPE_MONITOR; + eth_zero_addr(priv->mac_addr); + } mutex_unlock(&priv->conf_mutex); return err; } -- 2.34.1