On Sat, Nov 24, 2018 at 05:34:51PM +0800, Junchang Wang wrote: > Hi Paul, > > This is the patch sets for Section Deferred Processing. Please take a look. > > The first patch fixes a dependency issue in compiling route_hazptr.c. > > The second patch fixes a memory leak bug in hazptr.c. > > The last one fixes a typo in writing. > > > Thanks, > --Junchang Good catches, applied, thank you! On the memory-leak bug, I removed the "if" due to POSIX specifying that free() is a no-op when given a NULL pointer. http://pubs.opengroup.org/onlinepubs/009695399/functions/free.html Please see below for the updated commit, and please let me know if I messed anything up. Thanx, Paul > Junchang Wang (3): > route_hazptr: Add dependency to hazptr > route_hazptr: Fix a memory leak bug > defer: Fix a typo > > CodeSamples/defer/Makefile | 2 +- > CodeSamples/defer/hazptr.c | 4 ++++ > defer/hazptr.tex | 2 +- > 3 files changed, 6 insertions(+), 2 deletions(-) ------------------------------------------------------------------------ commit b8c1647f53ddedf10bf2973371f6f685dfd31d62 Author: Junchang Wang <junchangwang@xxxxxxxxx> Date: Sat Nov 24 17:34:53 2018 +0800 route_hazptr: Fix a memory leak bug Global pointer gplist is used to record hazard pointer array once it's allocated. This can avoid allocating and freeing hazptr array each time function hazptr_scan() is invoked. This patch fixes a memory leak bug and helps achieve the design goal. Signed-off-by: Junchang Wang <junchangwang@xxxxxxxxx> [ paulmck: Remove redundant "if" because free() ignores NULL argument. ] Signed-off-by: Paul E. McKenney <paulmck@xxxxxxxxxxxxx> diff --git a/CodeSamples/defer/hazptr.c b/CodeSamples/defer/hazptr.c index 91df310e24a2..fdb387e59ea1 100644 --- a/CodeSamples/defer/hazptr.c +++ b/CodeSamples/defer/hazptr.c @@ -53,6 +53,8 @@ void hazptr_thread_exit(void) hazptr_scan(); poll(NULL, 0, 1); } + + free(gplist); } void hazptr_reinitialize() @@ -103,6 +105,7 @@ void hazptr_scan() fprintf(stderr, "hazptr_scan: out of memory\n"); exit(EXIT_FAILURE); } + gplist = plist; } /*