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

Commit b6ebc455 authored by Ram Chandrasekar's avatar Ram Chandrasekar
Browse files

msm: limits: update the snprintf error handling



Update the snprintf() error handling in the
available_level_get() function to look for proper error
return value and take appropriate action.

Change-Id: Ifbe6450693a282105d9fddd02a756ae53d8cd892
Signed-off-by: default avatarRam Chandrasekar <rkumbako@codeaurora.org>
parent fc5413be
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -205,17 +205,23 @@ static ssize_t avail_level_get(struct device *dev,
		if (count + lvl_buf_count >= PAGE_SIZE) {
			pr_err("overflow.\n");
			break;
		} else if (count < 0) {
			pr_err("Error writing to buffer. err:%d\n", count);
			ret = count;
			goto lvl_get_exit;
		}
		lvl_buf_count += count;
	}
	count = snprintf(lvl_buf + lvl_buf_count, PAGE_SIZE - lvl_buf_count,
			"\n");
	if (count + lvl_buf_count < PAGE_SIZE)
	if (count < 0)
		pr_err("Error writing new line to buffer. err:%d\n", count);
	else if (count + lvl_buf_count < PAGE_SIZE)
		lvl_buf_count += count;

	count = snprintf(buf, lvl_buf_count + 1, lvl_buf);
	if (count > PAGE_SIZE) {
		pr_err("copy to user buf failed\n");
	if (count > PAGE_SIZE || count < 0) {
		pr_err("copy to user buffer failed\n");
		ret = -EFAULT;
		goto lvl_get_exit;
	}