All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch] tracing: Remove an unneeded check
@ 2012-04-20  6:31 ` Dan Carpenter
  0 siblings, 0 replies; 9+ messages in thread
From: Dan Carpenter @ 2012-04-20  6:31 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Frederic Weisbecker, Eduard - Gabriel Munteanu, Ingo Molnar,
	linux-kernel, kernel-janitors

memcpy() returns a pointer to "bug".  Hopefully, it's not NULL here or
we would already have Oopsed.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index ed7b5d1..c2d5b71 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -629,7 +629,6 @@ ssize_t trace_seq_to_user(struct trace_seq *s, char __user *ubuf, size_t cnt)
 static ssize_t trace_seq_to_buffer(struct trace_seq *s, void *buf, size_t cnt)
 {
 	int len;
-	void *ret;
 
 	if (s->len <= s->readpos)
 		return -EBUSY;
@@ -637,9 +636,7 @@ static ssize_t trace_seq_to_buffer(struct trace_seq *s, void *buf, size_t cnt)
 	len = s->len - s->readpos;
 	if (cnt > len)
 		cnt = len;
-	ret = memcpy(buf, s->buffer + s->readpos, cnt);
-	if (!ret)
-		return -EFAULT;
+	memcpy(buf, s->buffer + s->readpos, cnt);
 
 	s->readpos += cnt;
 	return cnt;

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

* [patch] tracing: Remove an unneeded check
@ 2012-04-20  6:31 ` Dan Carpenter
  0 siblings, 0 replies; 9+ messages in thread
From: Dan Carpenter @ 2012-04-20  6:31 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Frederic Weisbecker, Eduard - Gabriel Munteanu, Ingo Molnar,
	linux-kernel, kernel-janitors

memcpy() returns a pointer to "bug".  Hopefully, it's not NULL here or
we would already have Oopsed.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index ed7b5d1..c2d5b71 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -629,7 +629,6 @@ ssize_t trace_seq_to_user(struct trace_seq *s, char __user *ubuf, size_t cnt)
 static ssize_t trace_seq_to_buffer(struct trace_seq *s, void *buf, size_t cnt)
 {
 	int len;
-	void *ret;
 
 	if (s->len <= s->readpos)
 		return -EBUSY;
@@ -637,9 +636,7 @@ static ssize_t trace_seq_to_buffer(struct trace_seq *s, void *buf, size_t cnt)
 	len = s->len - s->readpos;
 	if (cnt > len)
 		cnt = len;
-	ret = memcpy(buf, s->buffer + s->readpos, cnt);
-	if (!ret)
-		return -EFAULT;
+	memcpy(buf, s->buffer + s->readpos, cnt);
 
 	s->readpos += cnt;
 	return cnt;

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

* Re: [patch] tracing: Remove an unneeded check
  2012-04-20  6:31 ` Dan Carpenter
@ 2012-04-20 13:51   ` Steven Rostedt
  -1 siblings, 0 replies; 9+ messages in thread
From: Steven Rostedt @ 2012-04-20 13:51 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Frederic Weisbecker, Eduard - Gabriel Munteanu, Ingo Molnar,
	linux-kernel, kernel-janitors

On Fri, 2012-04-20 at 09:31 +0300, Dan Carpenter wrote:
> memcpy() returns a pointer to "bug".  Hopefully, it's not NULL here or
> we would already have Oopsed.

You're right that the ret is useless, and the real bug was already fixed
(the possibility that buf could be an invalid pointer).

Not only is this needed, but also get rid of the ret < 0 check in
tracing_splice_read_pipe().

-- Steve



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

* Re: [patch] tracing: Remove an unneeded check
@ 2012-04-20 13:51   ` Steven Rostedt
  0 siblings, 0 replies; 9+ messages in thread
From: Steven Rostedt @ 2012-04-20 13:51 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Frederic Weisbecker, Eduard - Gabriel Munteanu, Ingo Molnar,
	linux-kernel, kernel-janitors

On Fri, 2012-04-20 at 09:31 +0300, Dan Carpenter wrote:
> memcpy() returns a pointer to "bug".  Hopefully, it's not NULL here or
> we would already have Oopsed.

You're right that the ret is useless, and the real bug was already fixed
(the possibility that buf could be an invalid pointer).

Not only is this needed, but also get rid of the ret < 0 check in
tracing_splice_read_pipe().

-- Steve



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

* Re: [patch] tracing: Remove an unneeded check
  2012-04-20 13:51   ` Steven Rostedt
@ 2012-04-20 14:03     ` Dan Carpenter
  -1 siblings, 0 replies; 9+ messages in thread
From: Dan Carpenter @ 2012-04-20 14:03 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Frederic Weisbecker, Eduard - Gabriel Munteanu, Ingo Molnar,
	linux-kernel, kernel-janitors

On Fri, Apr 20, 2012 at 09:51:21AM -0400, Steven Rostedt wrote:
> On Fri, 2012-04-20 at 09:31 +0300, Dan Carpenter wrote:
> > memcpy() returns a pointer to "bug".  Hopefully, it's not NULL here or
> > we would already have Oopsed.
> 
> You're right that the ret is useless, and the real bug was already fixed
> (the possibility that buf could be an invalid pointer).
> 
> Not only is this needed, but also get rid of the ret < 0 check in
> tracing_splice_read_pipe().
> 

We still return -EBUSY so we need the check.

regards,
dan carpenter


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

* Re: [patch] tracing: Remove an unneeded check
@ 2012-04-20 14:03     ` Dan Carpenter
  0 siblings, 0 replies; 9+ messages in thread
From: Dan Carpenter @ 2012-04-20 14:03 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Frederic Weisbecker, Eduard - Gabriel Munteanu, Ingo Molnar,
	linux-kernel, kernel-janitors

On Fri, Apr 20, 2012 at 09:51:21AM -0400, Steven Rostedt wrote:
> On Fri, 2012-04-20 at 09:31 +0300, Dan Carpenter wrote:
> > memcpy() returns a pointer to "bug".  Hopefully, it's not NULL here or
> > we would already have Oopsed.
> 
> You're right that the ret is useless, and the real bug was already fixed
> (the possibility that buf could be an invalid pointer).
> 
> Not only is this needed, but also get rid of the ret < 0 check in
> tracing_splice_read_pipe().
> 

We still return -EBUSY so we need the check.

regards,
dan carpenter


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

* Re: [patch] tracing: Remove an unneeded check
  2012-04-20 14:03     ` Dan Carpenter
@ 2012-04-20 14:26       ` Steven Rostedt
  -1 siblings, 0 replies; 9+ messages in thread
From: Steven Rostedt @ 2012-04-20 14:26 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Frederic Weisbecker, Eduard - Gabriel Munteanu, Ingo Molnar,
	linux-kernel, kernel-janitors

On Fri, 2012-04-20 at 17:03 +0300, Dan Carpenter wrote:
> On Fri, Apr 20, 2012 at 09:51:21AM -0400, Steven Rostedt wrote:
> > On Fri, 2012-04-20 at 09:31 +0300, Dan Carpenter wrote:
> > > memcpy() returns a pointer to "bug".  Hopefully, it's not NULL here or
> > > we would already have Oopsed.
> > 
> > You're right that the ret is useless, and the real bug was already fixed
> > (the possibility that buf could be an invalid pointer).
> > 
> > Not only is this needed, but also get rid of the ret < 0 check in
> > tracing_splice_read_pipe().
> > 
> 
> We still return -EBUSY so we need the check.

Hmm, you're right. I need to take a deeper look at this code. It looks
like it can be cleaned up a bit more (the splice code).

OK, your patch is good as is. I'll add it in my 3.5 queue, and add a
mental note to look at this code again.

Thanks,

-- Steve



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

* Re: [patch] tracing: Remove an unneeded check
@ 2012-04-20 14:26       ` Steven Rostedt
  0 siblings, 0 replies; 9+ messages in thread
From: Steven Rostedt @ 2012-04-20 14:26 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Frederic Weisbecker, Eduard - Gabriel Munteanu, Ingo Molnar,
	linux-kernel, kernel-janitors

On Fri, 2012-04-20 at 17:03 +0300, Dan Carpenter wrote:
> On Fri, Apr 20, 2012 at 09:51:21AM -0400, Steven Rostedt wrote:
> > On Fri, 2012-04-20 at 09:31 +0300, Dan Carpenter wrote:
> > > memcpy() returns a pointer to "bug".  Hopefully, it's not NULL here or
> > > we would already have Oopsed.
> > 
> > You're right that the ret is useless, and the real bug was already fixed
> > (the possibility that buf could be an invalid pointer).
> > 
> > Not only is this needed, but also get rid of the ret < 0 check in
> > tracing_splice_read_pipe().
> > 
> 
> We still return -EBUSY so we need the check.

Hmm, you're right. I need to take a deeper look at this code. It looks
like it can be cleaned up a bit more (the splice code).

OK, your patch is good as is. I'll add it in my 3.5 queue, and add a
mental note to look at this code again.

Thanks,

-- Steve



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

* [tip:perf/core] tracing: Remove an unneeded check in trace_seq_buffer()
  2012-04-20  6:31 ` Dan Carpenter
  (?)
  (?)
@ 2012-05-02 21:02 ` tip-bot for Dan Carpenter
  -1 siblings, 0 replies; 9+ messages in thread
From: tip-bot for Dan Carpenter @ 2012-05-02 21:02 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, fweisbec, rostedt, eduard.munteanu,
	tglx, dan.carpenter

Commit-ID:  5a26c8f0cf1e95106858bb4e23ca6dd14c9b842f
Gitweb:     http://git.kernel.org/tip/5a26c8f0cf1e95106858bb4e23ca6dd14c9b842f
Author:     Dan Carpenter <dan.carpenter@oracle.com>
AuthorDate: Fri, 20 Apr 2012 09:31:45 +0300
Committer:  Steven Rostedt <rostedt@goodmis.org>
CommitDate: Mon, 23 Apr 2012 21:16:10 -0400

tracing: Remove an unneeded check in trace_seq_buffer()

memcpy() returns a pointer to "bug".  Hopefully, it's not NULL here or
we would already have Oopsed.

Link: http://lkml.kernel.org/r/20120420063145.GA22649@elgon.mountain

Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Eduard - Gabriel Munteanu <eduard.munteanu@linux360.ro>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 kernel/trace/trace.c |    5 +----
 1 files changed, 1 insertions(+), 4 deletions(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 1ab8e35..bbcde54 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -629,7 +629,6 @@ ssize_t trace_seq_to_user(struct trace_seq *s, char __user *ubuf, size_t cnt)
 static ssize_t trace_seq_to_buffer(struct trace_seq *s, void *buf, size_t cnt)
 {
 	int len;
-	void *ret;
 
 	if (s->len <= s->readpos)
 		return -EBUSY;
@@ -637,9 +636,7 @@ static ssize_t trace_seq_to_buffer(struct trace_seq *s, void *buf, size_t cnt)
 	len = s->len - s->readpos;
 	if (cnt > len)
 		cnt = len;
-	ret = memcpy(buf, s->buffer + s->readpos, cnt);
-	if (!ret)
-		return -EFAULT;
+	memcpy(buf, s->buffer + s->readpos, cnt);
 
 	s->readpos += cnt;
 	return cnt;

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

end of thread, other threads:[~2012-05-02 21:02 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-20  6:31 [patch] tracing: Remove an unneeded check Dan Carpenter
2012-04-20  6:31 ` Dan Carpenter
2012-04-20 13:51 ` Steven Rostedt
2012-04-20 13:51   ` Steven Rostedt
2012-04-20 14:03   ` Dan Carpenter
2012-04-20 14:03     ` Dan Carpenter
2012-04-20 14:26     ` Steven Rostedt
2012-04-20 14:26       ` Steven Rostedt
2012-05-02 21:02 ` [tip:perf/core] tracing: Remove an unneeded check in trace_seq_buffer() tip-bot for Dan Carpenter

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.