Skip to content

Commit 3713a4e

Browse files
Yury Norovtorvalds
authored andcommitted
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>
1 parent 4e7301e commit 3713a4e

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

‎include/linux/cpumask.h‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -633,8 +633,7 @@ static inline int cpumask_parselist_user(const char __user *buf, int len,
633633
*/
634634
static inline int cpumask_parse(const char *buf, struct cpumask *dstp)
635635
{
636-
char *nl = strchr(buf, '\n');
637-
unsigned int len = nl ? (unsigned int)(nl - buf) : strlen(buf);
636+
unsigned int len = strchrnul(buf, '\n') - buf;
638637

639638
return bitmap_parse(buf, len, cpumask_bits(dstp), nr_cpumask_bits);
640639
}

0 commit comments

Comments
 (0)