diff options
-rw-r--r-- | drivers/char/ipmi/ipmi_watchdog.c | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/drivers/char/ipmi/ipmi_watchdog.c b/drivers/char/ipmi/ipmi_watchdog.c index 2d11ddd99e55..8f8867170973 100644 --- a/drivers/char/ipmi/ipmi_watchdog.c +++ b/drivers/char/ipmi/ipmi_watchdog.c | |||
@@ -212,24 +212,16 @@ static int set_param_str(const char *val, struct kernel_param *kp) | |||
212 | { | 212 | { |
213 | action_fn fn = (action_fn) kp->arg; | 213 | action_fn fn = (action_fn) kp->arg; |
214 | int rv = 0; | 214 | int rv = 0; |
215 | const char *end; | 215 | char *dup, *s; |
216 | char valcp[16]; | 216 | |
217 | int len; | 217 | dup = kstrdup(val, GFP_KERNEL); |
218 | 218 | if (!dup) | |
219 | /* Truncate leading and trailing spaces. */ | 219 | return -ENOMEM; |
220 | while (isspace(*val)) | 220 | |
221 | val++; | 221 | s = strstrip(dup); |
222 | end = val + strlen(val) - 1; | ||
223 | while ((end >= val) && isspace(*end)) | ||
224 | end--; | ||
225 | len = end - val + 1; | ||
226 | if (len > sizeof(valcp) - 1) | ||
227 | return -EINVAL; | ||
228 | memcpy(valcp, val, len); | ||
229 | valcp[len] = '\0'; | ||
230 | 222 | ||
231 | down_read(®ister_sem); | 223 | down_read(®ister_sem); |
232 | rv = fn(valcp, NULL); | 224 | rv = fn(s, NULL); |
233 | if (rv) | 225 | if (rv) |
234 | goto out_unlock; | 226 | goto out_unlock; |
235 | 227 | ||
@@ -239,6 +231,7 @@ static int set_param_str(const char *val, struct kernel_param *kp) | |||
239 | 231 | ||
240 | out_unlock: | 232 | out_unlock: |
241 | up_read(®ister_sem); | 233 | up_read(®ister_sem); |
234 | kfree(dup); | ||
242 | return rv; | 235 | return rv; |
243 | } | 236 | } |
244 | 237 | ||