Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 -1
+1 -1
drivers/base/regmap/regmap-debugfs.c
··· 432 432 /* If we're in the region the user is trying to read */ 433 433 if (p >= *ppos) { 434 434 /* ...but not beyond it */ 435 - if (buf_pos >= count - 1 - tot_len) 435 + if (buf_pos + tot_len + 1 >= count) 436 436 break; 437 437 438 438 /* Format the register */