diff options
Diffstat (limited to 'net/sunrpc/sysctl.c')
-rw-r--r-- | net/sunrpc/sysctl.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/net/sunrpc/sysctl.c b/net/sunrpc/sysctl.c index 887f0183b4c6..c88d9bc06f5c 100644 --- a/net/sunrpc/sysctl.c +++ b/net/sunrpc/sysctl.c | |||
@@ -76,7 +76,7 @@ static int | |||
76 | proc_dodebug(struct ctl_table *table, int write, | 76 | proc_dodebug(struct ctl_table *table, int write, |
77 | void __user *buffer, size_t *lenp, loff_t *ppos) | 77 | void __user *buffer, size_t *lenp, loff_t *ppos) |
78 | { | 78 | { |
79 | char tmpbuf[20], c, *s; | 79 | char tmpbuf[20], c, *s = NULL; |
80 | char __user *p; | 80 | char __user *p; |
81 | unsigned int value; | 81 | unsigned int value; |
82 | size_t left, len; | 82 | size_t left, len; |
@@ -103,23 +103,24 @@ proc_dodebug(struct ctl_table *table, int write, | |||
103 | return -EFAULT; | 103 | return -EFAULT; |
104 | tmpbuf[left] = '\0'; | 104 | tmpbuf[left] = '\0'; |
105 | 105 | ||
106 | for (s = tmpbuf, value = 0; '0' <= *s && *s <= '9'; s++, left--) | 106 | value = simple_strtol(tmpbuf, &s, 0); |
107 | value = 10 * value + (*s - '0'); | 107 | if (s) { |
108 | if (*s && !isspace(*s)) | 108 | left -= (s - tmpbuf); |
109 | return -EINVAL; | 109 | if (left && !isspace(*s)) |
110 | while (left && isspace(*s)) | 110 | return -EINVAL; |
111 | left--, s++; | 111 | while (left && isspace(*s)) |
112 | left--, s++; | ||
113 | } else | ||
114 | left = 0; | ||
112 | *(unsigned int *) table->data = value; | 115 | *(unsigned int *) table->data = value; |
113 | /* Display the RPC tasks on writing to rpc_debug */ | 116 | /* Display the RPC tasks on writing to rpc_debug */ |
114 | if (strcmp(table->procname, "rpc_debug") == 0) | 117 | if (strcmp(table->procname, "rpc_debug") == 0) |
115 | rpc_show_tasks(&init_net); | 118 | rpc_show_tasks(&init_net); |
116 | } else { | 119 | } else { |
117 | if (!access_ok(VERIFY_WRITE, buffer, left)) | 120 | len = sprintf(tmpbuf, "0x%04x", *(unsigned int *) table->data); |
118 | return -EFAULT; | ||
119 | len = sprintf(tmpbuf, "%d", *(unsigned int *) table->data); | ||
120 | if (len > left) | 121 | if (len > left) |
121 | len = left; | 122 | len = left; |
122 | if (__copy_to_user(buffer, tmpbuf, len)) | 123 | if (copy_to_user(buffer, tmpbuf, len)) |
123 | return -EFAULT; | 124 | return -EFAULT; |
124 | if ((left -= len) > 0) { | 125 | if ((left -= len) > 0) { |
125 | if (put_user('\n', (char __user *)buffer + len)) | 126 | if (put_user('\n', (char __user *)buffer + len)) |