msm: ipa3: add lock for num_q6_rule

There is a race condition be observed
on global variable num_q6_rule used in
ipa wan-driver. The fix is to add lock
to prevent different threads are accessing
it at the same time.

Change-Id: Ia9190c60361cb5605b61963309beca3acdeac89d
Signed-off-by: Skylar Chang <chiaweic@codeaurora.org>
This commit is contained in:
Skylar Chang 2017-08-11 15:49:21 -07:00 committed by Gerrit - the friendly Code Review server
parent 6b50124400
commit 2eaf14b921
1 changed files with 8 additions and 0 deletions

View File

@ -391,12 +391,15 @@ int copy_ul_filter_rule_to_ipa(struct ipa_install_fltr_rule_req_msg_v01
{
int i, j;
/* prevent multi-threads accessing num_q6_rule */
mutex_lock(&add_mux_channel_lock);
if (rule_req->filter_spec_list_valid == true) {
num_q6_rule = rule_req->filter_spec_list_len;
IPAWANDBG("Received (%d) install_flt_req\n", num_q6_rule);
} else {
num_q6_rule = 0;
IPAWANERR("got no UL rules from modem\n");
mutex_unlock(&add_mux_channel_lock);
return -EINVAL;
}
@ -590,9 +593,11 @@ failure:
num_q6_rule = 0;
memset(ipa_qmi_ctx->q6_ul_filter_rule, 0,
sizeof(ipa_qmi_ctx->q6_ul_filter_rule));
mutex_unlock(&add_mux_channel_lock);
return -EINVAL;
success:
mutex_unlock(&add_mux_channel_lock);
return 0;
}
@ -1434,6 +1439,8 @@ static int ipa_wwan_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
IPAWANERR("failed to config egress endpoint\n");
if (num_q6_rule != 0) {
/* protect num_q6_rule */
mutex_lock(&add_mux_channel_lock);
/* already got Q6 UL filter rules*/
if (ipa_qmi_ctx &&
ipa_qmi_ctx->modem_cfg_emb_pipe_flt
@ -1441,6 +1448,7 @@ static int ipa_wwan_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
rc = wwan_add_ul_flt_rule_to_ipa();
else
rc = 0;
mutex_unlock(&add_mux_channel_lock);
egress_set = true;
if (rc)
IPAWANERR("install UL rules failed\n");