From 7e2e2b96f50d17f301f1ee5505bf949c1d90204e Mon Sep 17 00:00:00 2001 From: Sebastian Ott Date: Mon, 20 Jan 2014 16:43:33 +0100 Subject: [PATCH] s390/xpram: don't modify module parameters During parsing of the sizes array the pointer to the particular string is lost. Keep it by using an extra pointer to store the end position of the parsed string. Keeping these parameters accessible can be helpful for debugging purposes and for userspace reading the parameters at runtime via sysfs. Also this will ensure that the memory is freed at module unload time. Reported-by: Michael Veigel Signed-off-by: Sebastian Ott Signed-off-by: Martin Schwidefsky --- drivers/s390/block/xpram.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/s390/block/xpram.c b/drivers/s390/block/xpram.c index 464dd29d06c0..58141f0651f2 100644 --- a/drivers/s390/block/xpram.c +++ b/drivers/s390/block/xpram.c @@ -257,6 +257,7 @@ static int __init xpram_setup_sizes(unsigned long pages) unsigned long mem_needed; unsigned long mem_auto; unsigned long long size; + char *sizes_end; int mem_auto_no; int i; @@ -275,8 +276,8 @@ static int __init xpram_setup_sizes(unsigned long pages) mem_auto_no = 0; for (i = 0; i < xpram_devs; i++) { if (sizes[i]) { - size = simple_strtoull(sizes[i], &sizes[i], 0); - switch (sizes[i][0]) { + size = simple_strtoull(sizes[i], &sizes_end, 0); + switch (*sizes_end) { case 'g': case 'G': size <<= 20; -- 2.34.1