Fix IPMI watchdog set_param_str() using kstrdup

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



  I've wondered for some time why my IPMI watchdog stopped working. I traced it
back to the following patch:

	[PATCH] ipmi: strstrip conversion

  Here is a patch to fix this issue.

  Sébastien.


                Fix IPMI watchdog set_param_str() using kstrdup

  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.


 ipmi_watchdog.c |   11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

Signed-off-by: Sébastien Dugué <[email protected]>

Index: linux-2.6.20-rc1/drivers/char/ipmi/ipmi_watchdog.c
===================================================================
--- linux-2.6.20-rc1.orig/drivers/char/ipmi/ipmi_watchdog.c	2006-12-14 02:14:23.000000000 +0100
+++ linux-2.6.20-rc1/drivers/char/ipmi/ipmi_watchdog.c	2006-12-19 17:20:06.000000000 +0100
@@ -216,13 +216,13 @@ static int set_param_str(const char *val
 {
 	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);
@@ -235,7 +235,6 @@ static int set_param_str(const char *val
 
  out_unlock:
 	up_read(&register_sem);
-	kfree(dup);
 	return rv;
 }
 
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux