If read_mem() goes before *map_address* has been mapped, dereference
to the *map_address*(nul) will cause the Segment Fault.

So, let read_mem() yield the CPU when *map_address* hasn't been mapped.


Which version do you prefer to?
Thanks

Signed-off-by: Wanlong Gao <[email protected]>
---
 testcases/kernel/mem/mtest06/mmap1.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/testcases/kernel/mem/mtest06/mmap1.c 
b/testcases/kernel/mem/mtest06/mmap1.c
index cd11912..0aa1c2b 100644
--- a/testcases/kernel/mem/mtest06/mmap1.c
+++ b/testcases/kernel/mem/mtest06/mmap1.c
@@ -352,6 +352,9 @@ read_mem(void *args)                /* number of reads 
performed                  */
     long       *rmargs = args; /* local pointer to the arguments             */
     long exit_val = 0;  /* pthread exit value                        */
 
+    while (!map_address)
+        sched_yield();
+
     tst_resm(TINFO, "pid[%d] - read contents of memory %p %ld times",
            getpid(), map_address, rmargs[2]);
     if (verbose_print)
@@ -608,4 +611,4 @@ main(int  argc,             /* number of input parameters.  
                      */
         close(fd);
     }while (TRUE);
     exit (0);
-}
\ No newline at end of file
+}
-- 
1.7.7.rc1


------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security
threats, fraudulent activity, and more. Splunk takes this data and makes
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2dcopy2
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to