perf_event: fix error handling path
PATCH 1/1 perf_event: fix error handling path
fix error handling path
kernel/perf_event.c | 2 -- 1 files changed, 0 insertions(+), 2 deletions(-)
kernel/perf_event.c +0 -2
@@ -1918,8 +1918,6 @@ static int get_callchain_buffers(void) } err =alloc_callchain_buffers (); -if (err) -release_callchain_buffers (); exit:mutex_unlock (&callchain_mutex);
Quoted 11 lines · On Sat, Dec 4, 2010 at 1:19 AM, <[email protected]> wrote:
fix error handling path
Signed-off-by Jovi Zhang <[email protected]>kernel/perf_event.c | 2 --
1 files changed, 0 insertions(+), 2 deletions(-)kernel/perf_event.c +0
-0
kernel/perf_event.c static int get_callchain_buffers(void) · line 1922
Quoted 5 lines
kernel/perf_event.c +0
-2@@ -1918,8 +1918,6 @@ static int get_callchain_buffers(void) } err = alloc_callchain_buffers(); - if (err) - release_callchain_buffers();
Care to explain in the change log message? As I reader, is not clear to me what is wrong with this.
Quoted 15 lines · Thiago Farina
Quoted 13 lines · On Sat, Dec 4, 2010 at 1:19 AM, <[email protected]> wrote:
fix error handling path
Signed-off-by Jovi Zhang <[email protected]>kernel/perf_event.c | 2 --
1 files changed, 0 insertions(+), 2 deletions(-)kernel/perf_event.c +0
-0@@ -1918,8 +1918,6 @@ static int get_callchain_buffers(void) }
Quoted 6 lines
kernel/perf_event.c static int get_callchain_buffers(void) · line 1922
Quoted 3 lines
kernel/perf_event.c +0
-2err = alloc_callchain_buffers(); - if (err) - release_callchain_buffers();Care to explain in the change log message? As I reader, is not clear to me what is wrong with this.
Sorry, the description should be as:
fix error handling path. alloc_callchain_buffers() can return -ENOMEM, in this time callchain_cpus_entries maybe is NULL, It will oops if invoke release_callchain_buffers() when callchain_cpus_entries is NULL.
Quoted 23 lines · jovi zhang
Quoted 15 lines · Thiago Farina
Quoted 13 lines · On Sat, Dec 4, 2010 at 1:19 AM, <[email protected]> wrote:
fix error handling path
Signed-off-by Jovi Zhang <[email protected]>kernel/perf_event.c | 2 --
1 files changed, 0 insertions(+), 2 deletions(-)kernel/perf_event.c +0
-0@@ -1918,8 +1918,6 @@ static int get_callchain_buffers(void) }Quoted 6 lines
kernel/perf_event.c static int get_callchain_buffers(void) · line 1922
Quoted 3 lines
kernel/perf_event.c +0
-2err = alloc_callchain_buffers(); - if (err) - release_callchain_buffers();Care to explain in the change log message? As I reader, is not clear to me what is wrong with this.
Quoted 6 lines
Sorry, the description should be as:
fix error handling path.alloc_callchain_buffers()can return-ENOMEM, in this time callchain_cpus_entries maybe is NULL, It will oops if invoke release_callchain_buffers() when callchain_cpus_entries is NULL.
I hope my understanding is right, is it?
Quoted 24 lines · jovi zhang
Quoted 23 lines · jovi zhang
Quoted 21 lines · Thiago Farina
Quoted 11 lines · On Sat, Dec 4, 2010 at 1:19 AM,<[email protected]> wrote:
fix error handling path
Signed-off-by Jovi Zhang<[email protected]>kernel/perf_event.c | 2 -- 1 files changed, 0 insertions(+), 2 deletions(-)kernel/perf_event.c +0
-0kernel/perf_event.c static int get_callchain_buffers(void) · line 1922
Quoted 5 lines
kernel/perf_event.c +0
-2@@ -1918,8 +1918,6 @@ static int get_callchain_buffers(void) } err =alloc_callchain_buffers (); -if (err) -release_callchain_buffers ();Care to explain in the change log message? As I reader, is not clear to me what is wrong with this.
Quoted 7 lines
Quoted 6 lines
Sorry, the description should be as:
fix error handling path.alloc_callchain_buffers()can return-ENOMEM, in this timecallchain_cpus_entriesmaybe is NULL, It will oops if invokerelease_callchain_buffers()whencallchain_cpus_entriesis NULL.I hope my understanding is right, is it?
One possible problem here is what if it returns an error other than -ENOMEM, and the buffers do need to be released? Maybe you could change the code to
err = alloc_callchain_buffers();
if (err != -ENOMEM)
release_callchain_buffers();
Currently, alloc_callchain_buffers cannot return any error code other than -ENOMEM, but that might change in the future.
- Corey
Quoted 37 lines · Corey Ashford
Quoted 24 lines · jovi zhang
Quoted 23 lines · jovi zhang
Quoted 21 lines · Thiago Farina
Quoted 11 lines · On Sat, Dec 4, 2010 at 1:19 AM,<[email protected]> wrote:
fix error handling path
Signed-off-by Jovi Zhang<[email protected]>kernel/perf_event.c | 2 -- 1 files changed, 0 insertions(+), 2 deletions(-)kernel/perf_event.c +0
-0kernel/perf_event.c static int get_callchain_buffers(void) · line 1922
Quoted 5 lines
kernel/perf_event.c +0
-2@@ -1918,8 +1918,6 @@ static int get_callchain_buffers(void) } err =alloc_callchain_buffers (); -if (err) -release_callchain_buffers ();Care to explain in the change log message? As I reader, is not clear to me what is wrong with this.
Quoted 7 lines
Quoted 6 lines
Sorry, the description should be as:
fix error handling path.alloc_callchain_buffers()can return-ENOMEM, in this timecallchain_cpus_entriesmaybe is NULL, It will oops if invokerelease_callchain_buffers()whencallchain_cpus_entriesis NULL.I hope my understanding is right, is it?
One possible problem here is what if it returns an error other than
-ENOMEM, and the buffers do need to be released? Maybe you could change the code to
Quoted 7 lines
err =
alloc_callchain_buffers();
if (err !=-ENOMEM)release_callchain_buffers();Currently,
alloc_callchain_bufferscannot return any error code other than-ENOMEM, but that might change in the future.
The kernel convention is to fully clean up after yourself if you return an error. So in that sense the patch seems right.
Anyway, anybody care to post a new patch with slightly extended changelog?
Quoted 34 lines · Peter Zijlstra
Quoted 33 lines · Corey Ashford
Quoted 31 lines · jovi zhang
Quoted 23 lines · jovi zhang
Quoted 15 lines · Thiago Farina
Quoted 13 lines · On Sat, Dec 4, 2010 at 1:19 AM,<[email protected]> wrote:
fix error handling path
Signed-off-by Jovi Zhang<[email protected]>
kernel/perf_event.c| 2 --1 files changed, 0 insertions(+), 2 deletions(-)kernel/perf_event.c +0
-0@@ -1918,8 +1918,6 @@ static int get_callchain_buffers(void) }Quoted 6 lines
kernel/perf_event.c static int get_callchain_buffers(void) · line 1922
Quoted 3 lines
kernel/perf_event.c +0
-2err = alloc_callchain_buffers(); - if (err) - release_callchain_buffers();Care to explain in the change log message? As I reader, is not clear to me what is wrong with this.
Quoted 6 lines
Sorry, the description should be as:
fix error handling path.alloc_callchain_buffers()can return-ENOMEM, in this timecallchain_cpus_entriesmaybe is NULL, It will oops if invokerelease_callchain_buffers()whencallchain_cpus_entriesis NULL.I hope my understanding is right, is it?
Quoted 8 lines
Quoted 8 lines
One possible problem here is what if it returns an error other than
-ENOMEM, and the buffers do need to be released? Maybe you could change the code toerr =
alloc_callchain_buffers();
if (err !=-ENOMEM)
release_callchain_buffers();
Thanks for you suggestion. I also thought it, but I think it should release the buffers in alloc_callchain_buffers if there have some error(like many other part of kernel code).
It's not a good way to trace return error code outside of alloc_callchain_buffer, if there have many return error code in future, maybe need to write code like this:if(err && err != -ENOMEM && err != -EXXX ) ...
It's very ugly. is right?
Quoted 10 lines
Quoted 3 lines
Currently,
alloc_callchain_bufferscannot return any error code other than-ENOMEM, but that might change in the future.The kernel convention is to fully clean up after yourself if you return an error. So in that sense the patch seems right.
Anyway, anybody care to post a new patch with slightly extended changelog?