aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2012-12-10 11:14:11 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-12-10 11:29:39 -0500
commitdb04328c167ff8e7c57f4a3532214aeada3a82fd (patch)
treea1c57616c3007b6d4fbb29a28f144ec89302917e /drivers
parentcbc1938badc31f43ab77e92a9b1a51c4fe8b4113 (diff)
regmap: debugfs: Avoid overflows for very small reads
If count is less than the size of a register then we may hit integer wraparound when trying to move backwards to check if we're still in the buffer. Instead move the position forwards to check if it's still in the buffer, we are unlikely to be able to allocate a buffer sufficiently big to overflow here. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Cc: stable@vger.kernel.org
Diffstat (limited to 'drivers')
-rw-r--r--drivers/base/regmap/regmap-debugfs.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/base/regmap/regmap-debugfs.c b/drivers/base/regmap/regmap-debugfs.c
index 00fbd58706b2..3df274e06062 100644
--- a/drivers/base/regmap/regmap-debugfs.c
+++ b/drivers/base/regmap/regmap-debugfs.c
@@ -93,7 +93,7 @@ static ssize_t regmap_read_debugfs(struct regmap *map, unsigned int from,
93 /* If we're in the region the user is trying to read */ 93 /* If we're in the region the user is trying to read */
94 if (p >= *ppos) { 94 if (p >= *ppos) {
95 /* ...but not beyond it */ 95 /* ...but not beyond it */
96 if (buf_pos >= count - 1 - map->debugfs_tot_len) 96 if (buf_pos + 1 + map->debugfs_tot_len >= count)
97 break; 97 break;
98 98
99 /* Format the register */ 99 /* Format the register */