Commit b82e116c authored by Eugene Teo's avatar Eugene Teo Committed by Hideaki Yoshifuji

[SUNRPC]: Handle copy_*_user and put_user errors

parent 0ffec775
...@@ -81,7 +81,8 @@ proc_dodebug(ctl_table *table, int write, struct file *file, ...@@ -81,7 +81,8 @@ proc_dodebug(ctl_table *table, int write, struct file *file,
if (left > sizeof(tmpbuf) - 1) if (left > sizeof(tmpbuf) - 1)
return -EINVAL; return -EINVAL;
copy_from_user(tmpbuf, p, left); if (copy_from_user(tmpbuf, p, left))
return -EFAULT;
tmpbuf[left] = '\0'; tmpbuf[left] = '\0';
for (p = tmpbuf, value = 0; '0' <= *p && *p <= '9'; p++, left--) for (p = tmpbuf, value = 0; '0' <= *p && *p <= '9'; p++, left--)
...@@ -101,9 +102,11 @@ proc_dodebug(ctl_table *table, int write, struct file *file, ...@@ -101,9 +102,11 @@ proc_dodebug(ctl_table *table, int write, struct file *file,
len = sprintf(tmpbuf, "%d", *(unsigned int *) table->data); len = sprintf(tmpbuf, "%d", *(unsigned int *) table->data);
if (len > left) if (len > left)
len = left; len = left;
__copy_to_user(buffer, tmpbuf, len); if (__copy_to_user(buffer, tmpbuf, len))
return -EFAULT;
if ((left -= len) > 0) { if ((left -= len) > 0) {
put_user('\n', (char *)buffer + len); if (put_user('\n', (char *)buffer + len))
return -EFAULT;
left--; left--;
} }
} }
......
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