]> Git Repo - linux.git/commitdiff
regmap: debugfs: Ensure we don't underflow when printing access masks
authorMark Brown <[email protected]>
Sat, 19 Sep 2015 14:00:18 +0000 (07:00 -0700)
committerMark Brown <[email protected]>
Sat, 19 Sep 2015 14:38:11 +0000 (07:38 -0700)
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 <[email protected]>
Signed-off-by: Mark Brown <[email protected]>
Cc: [email protected]
drivers/base/regmap/regmap-debugfs.c

index f42f2bac646623fc1db767bae3a5fff0ecf98aac..1f327898e53d12ffaf8c09a0bc3b9f573f973b1e 100644 (file)
@@ -432,7 +432,7 @@ static ssize_t regmap_access_read_file(struct file *file,
                /* If we're in the region the user is trying to read */
                if (p >= *ppos) {
                        /* ...but not beyond it */
-                       if (buf_pos >= count - 1 - tot_len)
+                       if (buf_pos + tot_len + 1 >= count)
                                break;
 
                        /* Format the register */
This page took 0.060237 seconds and 4 git commands to generate.