Skip to content

Commit 8ace60f

Browse files
committed
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
2 parents 07443ce + 176fc2d commit 8ace60f

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ static DEFINE_MUTEX(regmap_debugfs_early_lock);
3232
/* Calculate the length of a fixed format */
3333
static size_t regmap_calc_reg_len(int max_val, char *buf, size_t buf_size)
3434
{
35-
snprintf(buf, buf_size, "%x", max_val);
36-
return strlen(buf);
35+
return snprintf(NULL, 0, "%x", max_val);
3736
}
3837

3938
static ssize_t regmap_name_read_file(struct file *file,
@@ -432,7 +431,7 @@ static ssize_t regmap_access_read_file(struct file *file,
432431
/* If we're in the region the user is trying to read */
433432
if (p >= *ppos) {
434433
/* ...but not beyond it */
435-
if (buf_pos >= count - 1 - tot_len)
434+
if (buf_pos + tot_len + 1 >= count)
436435
break;
437436

438437
/* Format the register */

0 commit comments

Comments
 (0)