From: Dmitry Eremin Date: Sun, 29 Jan 2017 00:05:01 +0000 (-0500) Subject: staging: lustre: libcfs: avoid stomping on module param cpu_pattern X-Git-Tag: v4.11-rc1~116^2~173 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=c2351249f140aebdf911d86d7a1542c40b20fca3;p=karo-tx-linux.git staging: lustre: libcfs: avoid stomping on module param cpu_pattern The function cfs_cpt_table_create_pattern() alters the string passed to it. Currently we are passing in the module parameter string cpu_pattern which is incorrect. Instead lets duplicate the module parameter string and pass that to the function cfs_cpt_table_create_pattern(). Signed-off-by: Liang Zhen Signed-off-by: Dmitry Eremin Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5050 Reviewed-on: http://review.whamcloud.com/22377 Reviewed-by: James Simmons Reviewed-by: Olaf Weber Reviewed-by: Oleg Drokin Signed-off-by: James Simmons Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c b/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c index 427e2198bb9e..71a5b190ea5a 100644 --- a/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c +++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c @@ -1050,7 +1050,15 @@ cfs_cpu_init(void) ret = -EINVAL; if (*cpu_pattern) { - cfs_cpt_table = cfs_cpt_table_create_pattern(cpu_pattern); + char *cpu_pattern_dup = kstrdup(cpu_pattern, GFP_KERNEL); + + if (!cpu_pattern_dup) { + CERROR("Failed to duplicate cpu_pattern\n"); + goto failed; + } + + cfs_cpt_table = cfs_cpt_table_create_pattern(cpu_pattern_dup); + kfree(cpu_pattern_dup); if (!cfs_cpt_table) { CERROR("Failed to create cptab from pattern %s\n", cpu_pattern);