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

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 -3
+2 -3
drivers/base/regmap/regmap-debugfs.c
··· 32 32 /* Calculate the length of a fixed format */ 33 33 static size_t regmap_calc_reg_len(int max_val, char *buf, size_t buf_size) 34 34 { 35 - snprintf(buf, buf_size, "%x", max_val); 36 - return strlen(buf); 35 + return snprintf(NULL, 0, "%x", max_val); 37 36 } 38 37 39 38 static ssize_t regmap_name_read_file(struct file *file, ··· 431 432 /* If we're in the region the user is trying to read */ 432 433 if (p >= *ppos) { 433 434 /* ...but not beyond it */ 434 - if (buf_pos >= count - 1 - tot_len) 435 + if (buf_pos + tot_len + 1 >= count) 435 436 break; 436 437 437 438 /* Format the register */