X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fchar%2Fipmi%2Fipmi_watchdog.c;h=2d11ddd99e55e3439229ac2259695604cf2d008d;hb=9464c7cf61b9433057924c36e6e02f303a00e768;hp=accaaf1a6b697fb6c5604f290464a43d8b56a53f;hpb=41689045f6a3cbe0550e1d34e9cc20d2e8c432ba;p=linux-2.6.git diff --git a/drivers/char/ipmi/ipmi_watchdog.c b/drivers/char/ipmi/ipmi_watchdog.c index accaaf1a6..2d11ddd99 100644 --- a/drivers/char/ipmi/ipmi_watchdog.c +++ b/drivers/char/ipmi/ipmi_watchdog.c @@ -31,6 +31,7 @@ * 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include #include #include #include @@ -211,16 +212,24 @@ static int set_param_str(const char *val, struct kernel_param *kp) { action_fn fn = (action_fn) kp->arg; int rv = 0; - char *dup, *s; - - dup = kstrdup(val, GFP_KERNEL); - if (!dup) - return -ENOMEM; - - s = strstrip(dup); + const char *end; + char valcp[16]; + int len; + + /* Truncate leading and trailing spaces. */ + while (isspace(*val)) + val++; + end = val + strlen(val) - 1; + while ((end >= val) && isspace(*end)) + end--; + len = end - val + 1; + if (len > sizeof(valcp) - 1) + return -EINVAL; + memcpy(valcp, val, len); + valcp[len] = '\0'; down_read(®ister_sem); - rv = fn(s, NULL); + rv = fn(valcp, NULL); if (rv) goto out_unlock; @@ -230,7 +239,6 @@ static int set_param_str(const char *val, struct kernel_param *kp) out_unlock: up_read(®ister_sem); - kfree(dup); return rv; } @@ -807,7 +815,7 @@ static int ipmi_close(struct inode *ino, struct file *filep) return 0; } -static const struct file_operations ipmi_wdog_fops = { +static struct file_operations ipmi_wdog_fops = { .owner = THIS_MODULE, .read = ipmi_read, .poll = ipmi_poll, @@ -948,10 +956,9 @@ static int wdog_reboot_handler(struct notifier_block *this, /* Disable the WDT if we are shutting down. */ ipmi_watchdog_state = WDOG_TIMEOUT_NONE; panic_halt_ipmi_set_timeout(); - } else if (ipmi_watchdog_state != WDOG_TIMEOUT_NONE) { + } else { /* Set a long timer to let the reboot happens, but - reboot if it hangs, but only if the watchdog - timer was already running. */ + reboot if it hangs. */ timeout = 120; pretimeout = 0; ipmi_watchdog_state = WDOG_TIMEOUT_RESET; @@ -973,17 +980,16 @@ static int wdog_panic_handler(struct notifier_block *this, { static int panic_event_handled = 0; - /* On a panic, if we have a panic timeout, make sure to extend - the watchdog timer to a reasonable value to complete the - panic, if the watchdog timer is running. Plus the - pretimeout is meaningless at panic time. */ - if (watchdog_user && !panic_event_handled && - ipmi_watchdog_state != WDOG_TIMEOUT_NONE) { - /* Make sure we do this only once. */ + /* On a panic, if we have a panic timeout, make sure that the thing + reboots, even if it hangs during that panic. */ + if (watchdog_user && !panic_event_handled) { + /* Make sure the panic doesn't hang, and make sure we + do this only once. */ panic_event_handled = 1; timeout = 255; pretimeout = 0; + ipmi_watchdog_state = WDOG_TIMEOUT_RESET; panic_halt_ipmi_set_timeout(); }