aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2015-10-07 09:15:49 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2015-10-07 09:15:49 -0400
commit8ace60f8b760ff79aa2734e5e96223deae69f5f2 (patch)
tree331f41f2bed691a666157b5fb7ae263ce5b9cc83
parent07443cecdf68b4cf4c7d8ee0dbe0b2aa94c3e661 (diff)
parent176fc2d5770a0990eebff903ba680d2edd32e718 (diff)
Merge tag 'regmap-fix-v4.3-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap
Pull regmap fixes from Mark Brown: "A couple of fixes for the debugfs information on the register map, fixing issues with very small reads potentially causing underflows and wraparounds" * tag 'regmap-fix-v4.3-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap: regmap: debugfs: Don't bother actually printing when calculating max length regmap: debugfs: Ensure we don't underflow when printing access masks
-rw-r--r--drivers/base/regmap/regmap-debugfs.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/drivers/base/regmap/regmap-debugfs.c b/drivers/base/regmap/regmap-debugfs.c
index f42f2bac6466..4c55cfbad19e 100644
--- a/drivers/base/regmap/regmap-debugfs.c
+++ b/drivers/base/regmap/regmap-debugfs.c
@@ -32,8 +32,7 @@ static DEFINE_MUTEX(regmap_debugfs_early_lock);
32/* Calculate the length of a fixed format */ 32/* Calculate the length of a fixed format */
33static size_t regmap_calc_reg_len(int max_val, char *buf, size_t buf_size) 33static size_t regmap_calc_reg_len(int max_val, char *buf, size_t buf_size)
34{ 34{
35 snprintf(buf, buf_size, "%x", max_val); 35 return snprintf(NULL, 0, "%x", max_val);
36 return strlen(buf);
37} 36}
38 37
39static ssize_t regmap_name_read_file(struct file *file, 38static ssize_t regmap_name_read_file(struct file *file,
@@ -432,7 +431,7 @@ static ssize_t regmap_access_read_file(struct file *file,
432 /* If we're in the region the user is trying to read */ 431 /* If we're in the region the user is trying to read */
433 if (p >= *ppos) { 432 if (p >= *ppos) {
434 /* ...but not beyond it */ 433 /* ...but not beyond it */
435 if (buf_pos >= count - 1 - tot_len) 434 if (buf_pos + tot_len + 1 >= count)
436 break; 435 break;
437 436
438 /* Format the register */ 437 /* Format the register */