Commit c134d1f8 authored by Alex Dewar's avatar Alex Dewar Committed by Kalle Valo

ath11k: Handle errors if peer creation fails

ath11k_peer_create() is called without its return value being checked,
meaning errors will be unhandled. Add missing check and, as the mutex is
unconditionally unlocked on leaving this function, simplify the exit
path.

Addresses-Coverity-ID: 1497531 ("Code maintainability issues")
Fixes: 701e48a4 ("ath11k: add packet log support for QCA6390")
Signed-off-by: default avatarAlex Dewar <alex.dewar90@gmail.com>
Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20201004100218.311653-1-alex.dewar90@gmail.com
parent b96fab4e
...@@ -5275,20 +5275,26 @@ ath11k_mac_op_assign_vif_chanctx(struct ieee80211_hw *hw, ...@@ -5275,20 +5275,26 @@ ath11k_mac_op_assign_vif_chanctx(struct ieee80211_hw *hw,
arvif->vdev_type != WMI_VDEV_TYPE_AP && arvif->vdev_type != WMI_VDEV_TYPE_AP &&
arvif->vdev_type != WMI_VDEV_TYPE_MONITOR) { arvif->vdev_type != WMI_VDEV_TYPE_MONITOR) {
memcpy(&arvif->chanctx, ctx, sizeof(*ctx)); memcpy(&arvif->chanctx, ctx, sizeof(*ctx));
mutex_unlock(&ar->conf_mutex); ret = 0;
return 0; goto out;
} }
if (WARN_ON(arvif->is_started)) { if (WARN_ON(arvif->is_started)) {
mutex_unlock(&ar->conf_mutex); ret = -EBUSY;
return -EBUSY; goto out;
} }
if (ab->hw_params.vdev_start_delay) { if (ab->hw_params.vdev_start_delay) {
param.vdev_id = arvif->vdev_id; param.vdev_id = arvif->vdev_id;
param.peer_type = WMI_PEER_TYPE_DEFAULT; param.peer_type = WMI_PEER_TYPE_DEFAULT;
param.peer_addr = ar->mac_addr; param.peer_addr = ar->mac_addr;
ret = ath11k_peer_create(ar, arvif, NULL, &param); ret = ath11k_peer_create(ar, arvif, NULL, &param);
if (ret) {
ath11k_warn(ab, "failed to create peer after vdev start delay: %d",
ret);
goto out;
}
} }
ret = ath11k_mac_vdev_start(arvif, &ctx->def); ret = ath11k_mac_vdev_start(arvif, &ctx->def);
...@@ -5296,23 +5302,21 @@ ath11k_mac_op_assign_vif_chanctx(struct ieee80211_hw *hw, ...@@ -5296,23 +5302,21 @@ ath11k_mac_op_assign_vif_chanctx(struct ieee80211_hw *hw,
ath11k_warn(ab, "failed to start vdev %i addr %pM on freq %d: %d\n", ath11k_warn(ab, "failed to start vdev %i addr %pM on freq %d: %d\n",
arvif->vdev_id, vif->addr, arvif->vdev_id, vif->addr,
ctx->def.chan->center_freq, ret); ctx->def.chan->center_freq, ret);
goto err; goto out;
} }
if (arvif->vdev_type == WMI_VDEV_TYPE_MONITOR) { if (arvif->vdev_type == WMI_VDEV_TYPE_MONITOR) {
ret = ath11k_monitor_vdev_up(ar, arvif->vdev_id); ret = ath11k_monitor_vdev_up(ar, arvif->vdev_id);
if (ret) if (ret)
goto err; goto out;
} }
arvif->is_started = true; arvif->is_started = true;
/* TODO: Setup ps and cts/rts protection */ /* TODO: Setup ps and cts/rts protection */
mutex_unlock(&ar->conf_mutex); ret = 0;
return 0;
err: out:
mutex_unlock(&ar->conf_mutex); mutex_unlock(&ar->conf_mutex);
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