Browse Source

dataipa: Mutex lock the ipa_lnx_stats_ioctl

Mutex locking the ipa_lnx_stats ioctl.

Change-Id: Id1fe67cb5ad972dc501a0c1b5adb33b47d8dbaaa
Signed-off-by: Michael Adisumarta <[email protected]>
Michael Adisumarta 2 years ago
parent
commit
910a63643e
1 changed files with 4 additions and 0 deletions
  1. 4 0
      drivers/platform/msm/ipa/ipa_v3/ipa_stats.c

+ 4 - 0
drivers/platform/msm/ipa/ipa_v3/ipa_stats.c

@@ -52,6 +52,7 @@ static struct class *class;
 static dev_t device;
 
 struct ipa_lnx_stats_spearhead_ctx ipa_lnx_agent_ctx;
+static DEFINE_MUTEX(ipa_lnx_ctx_mutex);
 
 struct wlan_intf_mode_cnt {
 	u8 ap_cnt;
@@ -1765,6 +1766,7 @@ static long ipa_lnx_stats_ioctl(struct file *filp,
 		return -EPERM;
 	}
 
+	mutex_lock(&ipa_lnx_ctx_mutex);
 	switch (cmd) {
 	case IPA_LNX_IOC_GET_ALLOC_INFO:
 		retval = ipa_stats_get_alloc_info(arg);
@@ -1810,6 +1812,7 @@ static long ipa_lnx_stats_ioctl(struct file *filp,
 				const void __user *)arg, sizeof(struct ipa_lnx_consolidated_stats));
 		if (IS_ERR(consolidated_stats)) {
 			IPA_STATS_ERR("copy from user failed");
+			mutex_unlock(&ipa_lnx_ctx_mutex);
 			return -ENOMEM;
 		}
 
@@ -1868,6 +1871,7 @@ static long ipa_lnx_stats_ioctl(struct file *filp,
 	default:
 		retval = -ENOTTY;
 	}
+	mutex_unlock(&ipa_lnx_ctx_mutex);
 	return retval;
 }