Skip to content

Commit

Permalink
[PATCH] Fix IPMI watchdog set_param_str() using kstrdup
Browse files Browse the repository at this point in the history
set_param_str() cannot use kstrdup() to duplicate the parameter.  That's
fine when the driver is compiled as a module but it sure is not when built
into the kernel as the kernel parameters are parsed before the kmalloc
slabs are setup.

Signed-off-by: Sebastien Dugué <[email protected]>
Acked-by: Corey Minyard <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Sebastien Dugué authored and Linus Torvalds committed Dec 30, 2006
1 parent 7479b1c commit 43cdff9
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions drivers/char/ipmi/ipmi_watchdog.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,13 +216,13 @@ 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;
char valcp[16];
char *s;

dup = kstrdup(val, GFP_KERNEL);
if (!dup)
return -ENOMEM;
strncpy(valcp, val, 16);
valcp[15] = '\0';

s = strstrip(dup);
s = strstrip(valcp);

down_read(&register_sem);
rv = fn(s, NULL);
Expand All @@ -235,7 +235,6 @@ static int set_param_str(const char *val, struct kernel_param *kp)

out_unlock:
up_read(&register_sem);
kfree(dup);
return rv;
}

Expand Down

0 comments on commit 43cdff9

Please sign in to comment.