Commit 3f0b3c33 authored by Sebastian Ott's avatar Sebastian Ott Committed by Martin Schwidefsky

[S390] call home: fix local buffer usage in proc handler

Fix the size of the local buffer and use snprintf to prevent
further miscalculations. Also fix the usage of bitwise vs logic
operations.
Signed-off-by: default avatarSebastian Ott <sebott@linux.vnet.ibm.com>
Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
parent 964fe080
...@@ -68,15 +68,14 @@ static int proc_handler_callhome(struct ctl_table *ctl, int write, ...@@ -68,15 +68,14 @@ static int proc_handler_callhome(struct ctl_table *ctl, int write,
{ {
unsigned long val; unsigned long val;
int len, rc; int len, rc;
char buf[2]; char buf[3];
if (!*count | (*ppos && !write)) { if (!*count || (*ppos && !write)) {
*count = 0; *count = 0;
return 0; return 0;
} }
if (!write) { if (!write) {
len = sprintf(buf, "%d\n", callhome_enabled); len = snprintf(buf, sizeof(buf), "%d\n", callhome_enabled);
buf[len] = '\0';
rc = copy_to_user(buffer, buf, sizeof(buf)); rc = copy_to_user(buffer, buf, sizeof(buf));
if (rc != 0) if (rc != 0)
return -EFAULT; return -EFAULT;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment