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

Commit 27118f0c authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "diag: Add mutex protection while reading dci debug statistics"

parents 17998136 2c8247a1
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -50,7 +50,7 @@ static int diag_dbgfs_bridgeinfo_index;
static int diag_dbgfs_finished;
static int diag_dbgfs_dci_data_index;
static int diag_dbgfs_dci_finished;

static struct mutex diag_dci_dbgfs_mutex;
static ssize_t diag_dbgfs_read_status(struct file *file, char __user *ubuf,
				      size_t count, loff_t *ppos)
{
@@ -151,6 +151,7 @@ static ssize_t diag_dbgfs_read_dcistats(struct file *file,
	buf_size = ksize(buf);
	bytes_remaining = buf_size;

	mutex_lock(&diag_dci_dbgfs_mutex);
	if (diag_dbgfs_dci_data_index == 0) {
		bytes_written =
			scnprintf(buf, buf_size,
@@ -206,8 +207,8 @@ static ssize_t diag_dbgfs_read_dcistats(struct file *file,
		}
		temp_data++;
	}

	diag_dbgfs_dci_data_index = (i >= DIAG_DCI_DEBUG_CNT) ? 0 : i + 1;
	mutex_unlock(&diag_dci_dbgfs_mutex);
	bytes_written = simple_read_from_buffer(ubuf, count, ppos, buf,
								bytes_in_buf);
	kfree(buf);
@@ -1065,6 +1066,7 @@ int diag_debugfs_init(void)
		pr_warn("diag: could not allocate memory for dci debug info\n");

	mutex_init(&dci_stat_mutex);
	mutex_init(&diag_dci_dbgfs_mutex);
	return 0;
err:
	kfree(dci_traffic);
@@ -1081,6 +1083,7 @@ void diag_debugfs_cleanup(void)

	kfree(dci_traffic);
	mutex_destroy(&dci_stat_mutex);
	mutex_destroy(&diag_dci_dbgfs_mutex);
}
#else
int diag_debugfs_init(void) { return 0; }