summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinux Build Service Account <lnxbuild@quicinc.com>2017-06-01 01:53:07 -0700
committerGerrit - the friendly Code Review server <code-review@localhost>2017-06-01 01:53:07 -0700
commit864fd17d93b05cf0a77e37b3cca4c6880751e61c (patch)
treeb8980ab9a21e276d75d62c74a11c73bdb4e648e7
parent9037b7483cec836634b7a1ef4d456b12adf9b913 (diff)
parent7e45e3a6c1f6dd46d71fb6824a7cf702d2e79225 (diff)
Merge "diag: Synchronize command registration table access"
-rw-r--r--drivers/char/diag/diag_debugfs.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/char/diag/diag_debugfs.c b/drivers/char/diag/diag_debugfs.c
index 62ef9acc1df3..c963e4658c07 100644
--- a/drivers/char/diag/diag_debugfs.c
+++ b/drivers/char/diag/diag_debugfs.c
@@ -276,8 +276,10 @@ static ssize_t diag_dbgfs_read_table(struct file *file, char __user *ubuf,
struct list_head *temp;
struct diag_cmd_reg_t *item = NULL;
+ mutex_lock(&driver->cmd_reg_mutex);
if (diag_dbgfs_table_index == driver->cmd_reg_count) {
diag_dbgfs_table_index = 0;
+ mutex_unlock(&driver->cmd_reg_mutex);
return 0;
}
@@ -286,6 +288,7 @@ static ssize_t diag_dbgfs_read_table(struct file *file, char __user *ubuf,
buf = kzalloc(sizeof(char) * buf_size, GFP_KERNEL);
if (ZERO_OR_NULL_PTR(buf)) {
pr_err("diag: %s, Error allocating memory\n", __func__);
+ mutex_unlock(&driver->cmd_reg_mutex);
return -ENOMEM;
}
buf_size = ksize(buf);
@@ -330,6 +333,7 @@ static ssize_t diag_dbgfs_read_table(struct file *file, char __user *ubuf,
break;
}
diag_dbgfs_table_index = i;
+ mutex_unlock(&driver->cmd_reg_mutex);
*ppos = 0;
ret = simple_read_from_buffer(ubuf, count, ppos, buf, bytes_in_buffer);