Skip to content

Commit b763ec1

Browse files
committed
regmap: debugfs: Ensure we don't underflow when printing access masks
If a read is attempted which is smaller than the line length then we may underflow the subtraction we're doing with the unsigned size_t type so move some of the calculation to be additions on the right hand side instead in order to avoid this. Reported-by: Rasmus Villemoes <linux@rasmusvillemoes.dk> Signed-off-by: Mark Brown <broonie@kernel.org> Cc: stable@vger.kernel.org
1 parent 6ff33f3 commit b763ec1

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎drivers/base/regmap/regmap-debugfs.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ static ssize_t regmap_access_read_file(struct file *file,
432432
/* If we're in the region the user is trying to read */
433433
if (p >= *ppos) {
434434
/* ...but not beyond it */
435-
if (buf_pos >= count - 1 - tot_len)
435+
if (buf_pos + tot_len + 1 >= count)
436436
break;
437437

438438
/* Format the register */

0 commit comments

Comments
 (0)