Skip to content

Commit

Permalink
s390/xpram: don't modify module parameters
Browse files Browse the repository at this point in the history
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 <veigel@de.ibm.com>
Signed-off-by: Sebastian Ott <sebott@linux.vnet.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
  • Loading branch information
Sebastian Ott authored and Martin Schwidefsky committed Jan 22, 2014
1 parent 4dd841a commit 7e2e2b9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/s390/block/xpram.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand Down

0 comments on commit 7e2e2b9

Please sign in to comment.