summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRam Chandrasekar <rkumbako@codeaurora.org>2015-09-08 15:38:48 -0600
committerDavid Keitel <dkeitel@codeaurora.org>2016-03-23 21:15:26 -0700
commit1271a44387218fb9d625820bf3cc0db890b54143 (patch)
tree0d7d64af78d483cd9c1dd13b1f72529fc06dddf6
parent5c6e81fff64bf5711d776351b1c31f3136c968b7 (diff)
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: Ram Chandrasekar <rkumbako@codeaurora.org>
-rw-r--r--drivers/thermal/lmh_interface.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/drivers/thermal/lmh_interface.c b/drivers/thermal/lmh_interface.c
index 23ca02813941..ce3854cba1c5 100644
--- a/drivers/thermal/lmh_interface.c
+++ b/drivers/thermal/lmh_interface.c
@@ -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;
}