diff options
author | Tobias Klauser <tklauser@distanz.ch> | 2021-09-17 00:27:05 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2021-09-21 17:34:53 +0200 |
commit | c86a2d9058c5a4a05d20ef89e699b7a6b2c89da6 (patch) | |
tree | b5e8bfbd9790d02b6ba4aa731c96ee4331903aba /include | |
parent | af505cad9567f7a500d34bf183696d570d7f6810 (diff) | |
download | linux-c86a2d9058c5a4a05d20ef89e699b7a6b2c89da6.tar.bz2 |
cpumask: Omit terminating null byte in cpumap_print_{list,bitmask}_to_buf
The changes in the patch series [1] introduced a terminating null byte
when reading from cpulist or cpumap sysfs files, for example:
$ xxd /sys/devices/system/node/node0/cpulist
00000000: 302d 310a 00 0-1..
Before this change, the output looked as follows:
$ xxd /sys/devices/system/node/node0/cpulist
00000000: 302d 310a 0-1.
Fix this regression by excluding the terminating null byte from the
returned length in cpumap_print_list_to_buf and
cpumap_print_bitmask_to_buf.
[1] https://lore.kernel.org/all/20210806110251.560-1-song.bao.hua@hisilicon.com/
Fixes: 1fae562983ca ("cpumask: introduce cpumap_print_list/bitmask_to_buf to support large bitmask and list")
Acked-by: Barry Song <song.bao.hua@hisilicon.com>
Acked-by: Yury Norov <yury.norov@gmail.com>
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Link: https://lore.kernel.org/r/20210916222705.13554-1-tklauser@distanz.ch
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/cpumask.h | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h index 5d4d07a9e1ed..1e7399fc69c0 100644 --- a/include/linux/cpumask.h +++ b/include/linux/cpumask.h @@ -996,14 +996,15 @@ cpumap_print_to_pagebuf(bool list, char *buf, const struct cpumask *mask) * cpumask; Typically used by bin_attribute to export cpumask bitmask * ABI. * - * Returns the length of how many bytes have been copied. + * Returns the length of how many bytes have been copied, excluding + * terminating '\0'. */ static inline ssize_t cpumap_print_bitmask_to_buf(char *buf, const struct cpumask *mask, loff_t off, size_t count) { return bitmap_print_bitmask_to_buf(buf, cpumask_bits(mask), - nr_cpu_ids, off, count); + nr_cpu_ids, off, count) - 1; } /** @@ -1018,7 +1019,7 @@ cpumap_print_list_to_buf(char *buf, const struct cpumask *mask, loff_t off, size_t count) { return bitmap_print_list_to_buf(buf, cpumask_bits(mask), - nr_cpu_ids, off, count); + nr_cpu_ids, off, count) - 1; } #if NR_CPUS <= BITS_PER_LONG |