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

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

Merge "msm: camera: isp: Avoid stats data corruption."

parents c32cff49 b9c2cd1f
Loading
Loading
Loading
Loading
+23 −7
Original line number Diff line number Diff line
@@ -53,7 +53,6 @@ MODULE_DEVICE_TABLE(of, msm_vfe_dt_match);
#define MAX_OVERFLOW_COUNTERS  29
#define OVERFLOW_LENGTH 1024
#define OVERFLOW_BUFFER_LENGTH 64
static char stat_line[OVERFLOW_LENGTH];

struct msm_isp_statistics stats;
struct msm_isp_ub_info ub_info;
@@ -113,19 +112,30 @@ static int vfe_debugfs_statistics_open(struct inode *inode, struct file *file)
	return 0;
}

static ssize_t vfe_debugfs_statistics_read(struct file *t_file, char *t_char,
	size_t t_size_t, loff_t *t_loff_t)
static ssize_t vfe_debugfs_statistics_read(struct file *t_file,
	char __user *t_char, size_t t_size_t, loff_t *t_loff_t)
{
	int i;
	size_t rc;
	uint64_t *ptr;
	char buffer[OVERFLOW_BUFFER_LENGTH] = {0};
	char *stat_line;
	struct vfe_device *vfe_dev = (struct vfe_device *)
		t_file->private_data;
	struct msm_isp_statistics *stats = vfe_dev->stats;
	struct msm_isp_statistics *stats;

	memset(stat_line, 0, sizeof(stat_line));
	stat_line = kzalloc(OVERFLOW_LENGTH, GFP_KERNEL);
	if (!stat_line)
		return -ENOMEM;
	spin_lock(&vfe_dev->common_data->common_dev_data_lock);
	stats = vfe_dev->stats;
	msm_isp_util_get_bandwidth_stats(vfe_dev, stats);
	spin_unlock(&vfe_dev->common_data->common_dev_data_lock);
	ptr = (uint64_t *)(stats);
	if (MAX_OVERFLOW_COUNTERS > OVERFLOW_LENGTH) {
		kfree(stat_line);
		return -EINVAL;
	}
	for (i = 0; i < MAX_OVERFLOW_COUNTERS; i++) {
		strlcat(stat_line, stats_str[i], sizeof(stat_line));
		strlcat(stat_line, "     ", sizeof(stat_line));
@@ -133,8 +143,10 @@ static ssize_t vfe_debugfs_statistics_read(struct file *t_file, char *t_char,
		strlcat(stat_line, buffer, sizeof(stat_line));
		strlcat(stat_line, "\r\n", sizeof(stat_line));
	}
	return simple_read_from_buffer(t_char, t_size_t,
	rc = simple_read_from_buffer(t_char, t_size_t,
		t_loff_t, stat_line, strlen(stat_line));
	kfree(stat_line);
	return rc;
}

static ssize_t vfe_debugfs_statistics_write(struct file *t_file,
@@ -142,8 +154,12 @@ static ssize_t vfe_debugfs_statistics_write(struct file *t_file,
{
	struct vfe_device *vfe_dev = (struct vfe_device *)
		t_file->private_data;
	struct msm_isp_statistics *stats = vfe_dev->stats;
	struct msm_isp_statistics *stats;

	spin_lock(&vfe_dev->common_data->common_dev_data_lock);
	stats = vfe_dev->stats;
	memset(stats, 0, sizeof(struct msm_isp_statistics));
	spin_unlock(&vfe_dev->common_data->common_dev_data_lock);

	return sizeof(struct msm_isp_statistics);
}