Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8b49602c authored by Skylar Chang's avatar Skylar Chang Committed by Gerrit - the friendly Code Review server
Browse files

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: default avatarSkylar Chang <chiaweic@codeaurora.org>
parent 77b8b1c6
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -374,12 +374,15 @@ int copy_ul_filter_rule_to_ipa(struct ipa_install_fltr_rule_req_msg_v01
{
	int rc = 0, 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;
	}
	/* copy UL filter rules from Modem*/
@@ -523,6 +526,7 @@ int copy_ul_filter_rule_to_ipa(struct ipa_install_fltr_rule_req_msg_v01
			rule_req->filter_spec_list[i].filter_rule.
			ipv4_frag_eq_present;
	}
	mutex_unlock(&add_mux_channel_lock);
	return rc;
}

@@ -1301,8 +1305,11 @@ 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*/
				rc = wwan_add_ul_flt_rule_to_ipa();
				mutex_unlock(&add_mux_channel_lock);
				egress_set = true;
				if (rc)
					IPAWANERR("install UL rules failed\n");