* [PATCH 1/1] Fix Compilation Warning in kernel/trace/trace.c
@ 2011-12-16 7:15 Devendra Naga
2011-12-16 12:40 ` Steven Rostedt
0 siblings, 1 reply; 3+ messages in thread
From: Devendra Naga @ 2011-12-16 7:15 UTC (permalink / raw)
To: rostedt, fweisbec, mingo, linux-kernel; +Cc: Devendra Naga
there was a compilation warning saying
kernel/trace/trace.c:3644:8: warning: ‘page2’ may be used uninitialized in this function
The page2 pointer is used only when nr_pages = 2.
Assigned a null value to the page2 to get rid of warning.
Signed-off-by: Devendra Naga <devendra.aaru@gmail.com>
---
kernel/trace/trace.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index f2bd275..80dfd92 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -3641,7 +3641,7 @@ tracing_mark_write(struct file *filp, const char __user *ubuf,
int nr_pages = 1;
ssize_t written;
void *page1;
- void *page2;
+ void *page2 = NULL;
int offset;
int size;
int len;
--
1.7.4.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/1] Fix Compilation Warning in kernel/trace/trace.c
2011-12-16 7:15 [PATCH 1/1] Fix Compilation Warning in kernel/trace/trace.c Devendra Naga
@ 2011-12-16 12:40 ` Steven Rostedt
[not found] ` <CAHdPZaN3KQRqSOMXV7HdJkw_T_J5D3s3pxDXY72V4iT_tR9NBQ@mail.gmail.com>
0 siblings, 1 reply; 3+ messages in thread
From: Steven Rostedt @ 2011-12-16 12:40 UTC (permalink / raw)
To: Devendra Naga; +Cc: fweisbec, mingo, linux-kernel
On Fri, 2011-12-16 at 02:15 -0500, Devendra Naga wrote:
> there was a compilation warning saying
> kernel/trace/trace.c:3644:8: warning: ‘page2’ may be used uninitialized in this function
Nacked-by: Steven Rostedt <rostedt@goodmis.org>
And I also nacked this same fix here:
https://lkml.org/lkml/2011/11/28/287
>
> The page2 pointer is used only when nr_pages = 2.
>
> Assigned a null value to the page2 to get rid of warning.
Please please please, do not just fix warnings without actually looking
at the code.
1) this is a bug in the compiler, which happens to be fixed in newer
compilers (which does not produce this warning). It just happens that
gcc couldn't tell the simple usage of:
if (nr_pages == 2)
page2 = kmap_atomic(pages[1]);
and later:
if (nr_pages == 2) {
len = PAGE_SIZE - offset;
memcpy(&entry->buf, page1 + offset, len);
memcpy(&entry->buf[len], page2, cnt - len);
and finally:
if (nr_pages == 2)
kunmap_atomic(page2);
nr_pages never changes during this code. Gcc probably got confused
because on error exit, it does change (to unmap everything).
2) But your fix is still wrong!
Initializing it to NULL is wrong! Because it would hide a kernel bug if
page2 was really used uninitialized. As passing NULL as the source of
memcpy will panic the kernel.
Again, do not just randomly post fixes to gcc warnings without
understanding the real fix.
Thanks,
-- Steve
>
> Signed-off-by: Devendra Naga <devendra.aaru@gmail.com>
> ---
> kernel/trace/trace.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
> index f2bd275..80dfd92 100644
> --- a/kernel/trace/trace.c
> +++ b/kernel/trace/trace.c
> @@ -3641,7 +3641,7 @@ tracing_mark_write(struct file *filp, const char __user *ubuf,
> int nr_pages = 1;
> ssize_t written;
> void *page1;
> - void *page2;
> + void *page2 = NULL;
> int offset;
> int size;
> int len;
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/1] Fix Compilation Warning in kernel/trace/trace.c
[not found] ` <CAHdPZaN3KQRqSOMXV7HdJkw_T_J5D3s3pxDXY72V4iT_tR9NBQ@mail.gmail.com>
@ 2011-12-16 15:28 ` Steven Rostedt
0 siblings, 0 replies; 3+ messages in thread
From: Steven Rostedt @ 2011-12-16 15:28 UTC (permalink / raw)
To: devendra.aaru; +Cc: fweisbec, mingo, linux-kernel
On Fri, 2011-12-16 at 08:13 -0500, devendra.aaru wrote:
>
>
> I m very sorry sir ....
No need to be sorry ;)
Just spend a bit more time looking at what you fix next time :)
-- Steve
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-12-16 15:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-16 7:15 [PATCH 1/1] Fix Compilation Warning in kernel/trace/trace.c Devendra Naga
2011-12-16 12:40 ` Steven Rostedt
[not found] ` <CAHdPZaN3KQRqSOMXV7HdJkw_T_J5D3s3pxDXY72V4iT_tR9NBQ@mail.gmail.com>
2011-12-16 15:28 ` Steven Rostedt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox