public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] blktrace: pass the right pointer to kfree()
@ 2009-04-09  3:19 Li Zefan
  2009-04-09  4:36 ` [tip:tracing/urgent] " Li Zefan
  2009-04-09 13:13 ` [PATCH] " Arnaldo Carvalho de Melo
  0 siblings, 2 replies; 3+ messages in thread
From: Li Zefan @ 2009-04-09  3:19 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Jens Axboe, Arnaldo Carvalho de Melo, LKML

If passing a string with leading white spaces to strstrip(),
the returned ptr != the original ptr.

This bug was introduced by me.

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
---
 kernel/trace/blktrace.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
index b32ff44..921ef5d 100644
--- a/kernel/trace/blktrace.c
+++ b/kernel/trace/blktrace.c
@@ -1377,12 +1377,12 @@ static int blk_trace_str2mask(const char *str)
 {
 	int i;
 	int mask = 0;
-	char *s, *token;
+	char *buf, *s, *token;
 
-	s = kstrdup(str, GFP_KERNEL);
-	if (s == NULL)
+	buf = kstrdup(str, GFP_KERNEL);
+	if (buf == NULL)
 		return -ENOMEM;
-	s = strstrip(s);
+	s = strstrip(buf);
 
 	while (1) {
 		token = strsep(&s, ",");
@@ -1403,7 +1403,7 @@ static int blk_trace_str2mask(const char *str)
 			break;
 		}
 	}
-	kfree(s);
+	kfree(buf);
 
 	return mask;
 }
-- 
1.5.4.rc3

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [tip:tracing/urgent] blktrace: pass the right pointer to kfree()
  2009-04-09  3:19 [PATCH] blktrace: pass the right pointer to kfree() Li Zefan
@ 2009-04-09  4:36 ` Li Zefan
  2009-04-09 13:13 ` [PATCH] " Arnaldo Carvalho de Melo
  1 sibling, 0 replies; 3+ messages in thread
From: Li Zefan @ 2009-04-09  4:36 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, acme, hpa, mingo, lizf, jens.axboe, tglx, mingo

Commit-ID:  9eb85125ce218a8b8d9a7c982510388e227adbec
Gitweb:     http://git.kernel.org/tip/9eb85125ce218a8b8d9a7c982510388e227adbec
Author:     Li Zefan <lizf@cn.fujitsu.com>
AuthorDate: Thu, 9 Apr 2009 11:19:40 +0800
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Thu, 9 Apr 2009 05:52:40 +0200

blktrace: pass the right pointer to kfree()

Impact: fix kfree crash with non-standard act_mask string

If passing a string with leading white spaces to strstrip(),
the returned ptr != the original ptr.

This bug was introduced by me.

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Cc: Jens Axboe <jens.axboe@oracle.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
LKML-Reference: <49DD694C.8020902@cn.fujitsu.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>


---
 kernel/trace/blktrace.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
index b32ff44..921ef5d 100644
--- a/kernel/trace/blktrace.c
+++ b/kernel/trace/blktrace.c
@@ -1377,12 +1377,12 @@ static int blk_trace_str2mask(const char *str)
 {
 	int i;
 	int mask = 0;
-	char *s, *token;
+	char *buf, *s, *token;
 
-	s = kstrdup(str, GFP_KERNEL);
-	if (s == NULL)
+	buf = kstrdup(str, GFP_KERNEL);
+	if (buf == NULL)
 		return -ENOMEM;
-	s = strstrip(s);
+	s = strstrip(buf);
 
 	while (1) {
 		token = strsep(&s, ",");
@@ -1403,7 +1403,7 @@ static int blk_trace_str2mask(const char *str)
 			break;
 		}
 	}
-	kfree(s);
+	kfree(buf);
 
 	return mask;
 }

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] blktrace: pass the right pointer to kfree()
  2009-04-09  3:19 [PATCH] blktrace: pass the right pointer to kfree() Li Zefan
  2009-04-09  4:36 ` [tip:tracing/urgent] " Li Zefan
@ 2009-04-09 13:13 ` Arnaldo Carvalho de Melo
  1 sibling, 0 replies; 3+ messages in thread
From: Arnaldo Carvalho de Melo @ 2009-04-09 13:13 UTC (permalink / raw)
  To: Li Zefan; +Cc: Ingo Molnar, Jens Axboe, LKML

Em Thu, Apr 09, 2009 at 11:19:40AM +0800, Li Zefan escreveu:
> If passing a string with leading white spaces to strstrip(),
> the returned ptr != the original ptr.
> 
> This bug was introduced by me.
> 
> Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>

I hadn't noticed that strstrip was added, oops.

Acked-by: Arnaldo Carvalho de Melo <acme@redhat.com>

> ---
>  kernel/trace/blktrace.c |   10 +++++-----
>  1 files changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
> index b32ff44..921ef5d 100644
> --- a/kernel/trace/blktrace.c
> +++ b/kernel/trace/blktrace.c
> @@ -1377,12 +1377,12 @@ static int blk_trace_str2mask(const char *str)
>  {
>  	int i;
>  	int mask = 0;
> -	char *s, *token;
> +	char *buf, *s, *token;
>  
> -	s = kstrdup(str, GFP_KERNEL);
> -	if (s == NULL)
> +	buf = kstrdup(str, GFP_KERNEL);
> +	if (buf == NULL)
>  		return -ENOMEM;
> -	s = strstrip(s);
> +	s = strstrip(buf);
>  
>  	while (1) {
>  		token = strsep(&s, ",");
> @@ -1403,7 +1403,7 @@ static int blk_trace_str2mask(const char *str)
>  			break;
>  		}
>  	}
> -	kfree(s);
> +	kfree(buf);
>  
>  	return mask;
>  }
> -- 
> 1.5.4.rc3

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-04-09 13:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-09  3:19 [PATCH] blktrace: pass the right pointer to kfree() Li Zefan
2009-04-09  4:36 ` [tip:tracing/urgent] " Li Zefan
2009-04-09 13:13 ` [PATCH] " Arnaldo Carvalho de Melo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox