diff options
author | Yury Norov <ynorov@marvell.com> | 2019-05-15 01:44:46 +0300 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2019-05-15 05:52:50 +0300 |
commit | 3713a4e1fdb8da86f96a3e770b08e278d97529b4 (patch) | |
tree | 724fa45759fee26161ee2c34e9c060a431561cfe /include | |
parent | 4e7301e6df9595e34e52acc18b943d00c4865e3d (diff) | |
download | linux-3713a4e1fdb8da86f96a3e770b08e278d97529b4.tar.xz |
include/linux/cpumask.h: fix double string traverse in cpumask_parse
cpumask_parse() finds first occurrence of either or strchr() and
strlen(). We can do it better with a single call of strchrnul().
[akpm@linux-foundation.org: remove unneeded cast]
Link: http://lkml.kernel.org/r/20190409204208.12190-1-ynorov@marvell.com
Signed-off-by: Yury Norov <ynorov@marvell.com>
Acked-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/cpumask.h | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h index 147bdec42215..21755471b1c3 100644 --- a/include/linux/cpumask.h +++ b/include/linux/cpumask.h @@ -633,8 +633,7 @@ static inline int cpumask_parselist_user(const char __user *buf, int len, */ static inline int cpumask_parse(const char *buf, struct cpumask *dstp) { - char *nl = strchr(buf, '\n'); - unsigned int len = nl ? (unsigned int)(nl - buf) : strlen(buf); + unsigned int len = strchrnul(buf, '\n') - buf; return bitmap_parse(buf, len, cpumask_bits(dstp), nr_cpumask_bits); } |