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 <liang.zhen@intel.com>
Signed-off-by: Dmitry Eremin <dmitry.eremin@intel.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5050
Reviewed-on: http://review.whamcloud.com/22377
Reviewed-by: James Simmons <uja.ornl@yahoo.com>
Reviewed-by: Olaf Weber <olaf@sgi.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Dmitry Eremin 2017-01-28 19:05:01 -05:00 committed by Greg Kroah-Hartman
parent aabb4adadd
commit c2351249f1
1 changed files with 9 additions and 1 deletions

View File

@ -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);