提交 28269897 编写于 作者: J Johannes Berg 提交者: Luca Coelho

iwlwifi: mvm: make iwl_mvm_update_mcc() easier to follow

Some static checkers (e.g. smatch) complain about the logic, saying that
resp_cp might be leaked. Clearly that isn't true, but making the logic
easier to follow does not result in any significant code changes and makes
the code more readable by moving the NULL check closer to its source.
Signed-off-by: NJohannes Berg <johannes.berg@intel.com>
Signed-off-by: NLuca Coelho <luciano.coelho@intel.com>
上级 e9eb0fa2
...@@ -779,6 +779,10 @@ iwl_mvm_update_mcc(struct iwl_mvm *mvm, const char *alpha2, ...@@ -779,6 +779,10 @@ iwl_mvm_update_mcc(struct iwl_mvm *mvm, const char *alpha2,
resp_len = sizeof(struct iwl_mcc_update_resp) + resp_len = sizeof(struct iwl_mcc_update_resp) +
n_channels * sizeof(__le32); n_channels * sizeof(__le32);
resp_cp = kmemdup(mcc_resp, resp_len, GFP_KERNEL); resp_cp = kmemdup(mcc_resp, resp_len, GFP_KERNEL);
if (!resp_cp) {
resp_cp = ERR_PTR(-ENOMEM);
goto exit;
}
} else { } else {
struct iwl_mcc_update_resp_v1 *mcc_resp_v1 = (void *)pkt->data; struct iwl_mcc_update_resp_v1 *mcc_resp_v1 = (void *)pkt->data;
...@@ -786,21 +790,18 @@ iwl_mvm_update_mcc(struct iwl_mvm *mvm, const char *alpha2, ...@@ -786,21 +790,18 @@ iwl_mvm_update_mcc(struct iwl_mvm *mvm, const char *alpha2,
resp_len = sizeof(struct iwl_mcc_update_resp) + resp_len = sizeof(struct iwl_mcc_update_resp) +
n_channels * sizeof(__le32); n_channels * sizeof(__le32);
resp_cp = kzalloc(resp_len, GFP_KERNEL); resp_cp = kzalloc(resp_len, GFP_KERNEL);
if (!resp_cp) {
if (resp_cp) { resp_cp = ERR_PTR(-ENOMEM);
resp_cp->status = mcc_resp_v1->status; goto exit;
resp_cp->mcc = mcc_resp_v1->mcc;
resp_cp->cap = mcc_resp_v1->cap;
resp_cp->source_id = mcc_resp_v1->source_id;
resp_cp->n_channels = mcc_resp_v1->n_channels;
memcpy(resp_cp->channels, mcc_resp_v1->channels,
n_channels * sizeof(__le32));
} }
}
if (!resp_cp) { resp_cp->status = mcc_resp_v1->status;
ret = -ENOMEM; resp_cp->mcc = mcc_resp_v1->mcc;
goto exit; resp_cp->cap = mcc_resp_v1->cap;
resp_cp->source_id = mcc_resp_v1->source_id;
resp_cp->n_channels = mcc_resp_v1->n_channels;
memcpy(resp_cp->channels, mcc_resp_v1->channels,
n_channels * sizeof(__le32));
} }
status = le32_to_cpu(resp_cp->status); status = le32_to_cpu(resp_cp->status);
...@@ -820,8 +821,6 @@ iwl_mvm_update_mcc(struct iwl_mvm *mvm, const char *alpha2, ...@@ -820,8 +821,6 @@ iwl_mvm_update_mcc(struct iwl_mvm *mvm, const char *alpha2,
exit: exit:
iwl_free_resp(&cmd); iwl_free_resp(&cmd);
if (ret)
return ERR_PTR(ret);
return resp_cp; return resp_cp;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册