All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Sébastien Dugué" <sebastien.dugue@bull.net>
To: Linus Torvalds <torvalds@osdl.org>
Cc: linux-kernel <linux-kernel@vger.kernel.org>,
	Pekka Enberg <penberg@cs.helsinki.fi>,
	Jean Pierre Dion <jean-pierre.dion@bull.net>
Subject: Fix IPMI watchdog set_param_str() using kstrdup
Date: Wed, 20 Dec 2006 12:05:44 +0100	[thread overview]
Message-ID: <20061220120544.36fdf518@frecb000686> (raw)


  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é <sebastien.dugue@bull.net>

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;
 }
 

             reply	other threads:[~2006-12-20 11:05 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-12-20 11:05 Sébastien Dugué [this message]
2006-12-20 11:19 ` Fix IPMI watchdog set_param_str() using kstrdup Pekka Enberg
2006-12-20 11:32   ` Sébastien Dugué

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20061220120544.36fdf518@frecb000686 \
    --to=sebastien.dugue@bull.net \
    --cc=jean-pierre.dion@bull.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=penberg@cs.helsinki.fi \
    --cc=torvalds@osdl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.