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

Commit c0121403 authored by Lloyd Atkinson's avatar Lloyd Atkinson
Browse files

drm/msm: check offset alignment in register debug functions



Add checks against alignment for the offset parameter to guard
against unaligned memory access problems.

Change-Id: I961859c8194616fea0ba610d2766e165a1d9656a
Signed-off-by: default avatarLloyd Atkinson <latkinso@codeaurora.org>
parent 7529b53b
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -2723,6 +2723,9 @@ static ssize_t sde_dbg_reg_base_offset_write(struct file *file,
	if (off > dbg->max_offset)
		return -EINVAL;

	if (off % sizeof(u32))
		return -EINVAL;

	if (cnt > (dbg->max_offset - off))
		cnt = dbg->max_offset - off;

@@ -2754,6 +2757,9 @@ static ssize_t sde_dbg_reg_base_offset_read(struct file *file,
	if (*ppos)
		return 0;	/* the end */

	if (dbg->off % sizeof(u32))
		return -EFAULT;

	len = snprintf(buf, sizeof(buf), "0x%08zx %zx\n", dbg->off, dbg->cnt);
	if (len < 0 || len >= sizeof(buf))
		return 0;
@@ -2797,6 +2803,9 @@ static ssize_t sde_dbg_reg_base_reg_write(struct file *file,
	if (cnt < 2)
		return -EFAULT;

	if (off % sizeof(u32))
		return -EFAULT;

	if (off >= dbg->max_offset)
		return -EFAULT;

@@ -2841,6 +2850,9 @@ static ssize_t sde_dbg_reg_base_reg_read(struct file *file,
		if (!dbg->buf)
			return -ENOMEM;

		if (dbg->off % sizeof(u32))
			return -EFAULT;

		ptr = dbg->base + dbg->off;
		tot = 0;