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

Commit f198a02d authored by Chirag Khurana's avatar Chirag Khurana Committed by Gerrit - the friendly Code Review server
Browse files

disp: msm: dsi: add check before buffer copy



This change adds a check for the length of the buffer
before copying it to avoid a buffer overflow.

Change-Id: I146895660be4060d9896706636257a57c6aef94f
Signed-off-by: default avatarVishnuvardhan Prodduturi <vproddut@codeaurora.org>
Signed-off-by: default avatarChirag Khurana <ckhurana@codeaurora.org>
parent e03f5b77
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -124,7 +124,7 @@ static ssize_t debugfs_state_info_read(struct file *file,
	if (len > count)
	if (len > count)
		len = count;
		len = count;


	/* TODO: make sure that this does not exceed 4K */
	len = min_t(size_t, len, SZ_4K);
	if (copy_to_user(buff, buf, len)) {
	if (copy_to_user(buff, buf, len)) {
		kfree(buf);
		kfree(buf);
		return -EFAULT;
		return -EFAULT;
@@ -182,7 +182,7 @@ static ssize_t debugfs_reg_dump_read(struct file *file,
	if (len > count)
	if (len > count)
		len = count;
		len = count;


	/* TODO: make sure that this does not exceed 4K */
	len = min_t(size_t, len, SZ_4K);
	if (copy_to_user(buff, buf, len)) {
	if (copy_to_user(buff, buf, len)) {
		kfree(buf);
		kfree(buf);
		return -EFAULT;
		return -EFAULT;