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

Commit 0543cd39 authored by Yuanfang Zhang's avatar Yuanfang Zhang
Browse files

soc: qcom: dcc: avoid memory access violation



When *ppos + len is overflow, shrink len to max readable size
of SRAM.

Change-Id: I7c35433d384eb596a3f84b7ce13652f58166b40a
Signed-off-by: default avatarYuanfang Zhang <zhangyuanfang@codeaurora.org>
parent a9e3b4c7
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -1558,7 +1558,8 @@ static ssize_t dcc_sram_read(struct file *file, char __user *data,
	if (drvdata->ram_size <= *ppos)
		return 0;

	if ((*ppos + len) > drvdata->ram_size)
	if ((*ppos + len) < len
		|| (*ppos + len) > drvdata->ram_size)
		len = (drvdata->ram_size - *ppos);

	buf = kzalloc(len, GFP_KERNEL);