On 09/30/2011 01:30 PM, Wanlong Gao wrote: > 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. > > Signed-off-by: Wanlong Gao <[email protected]> > --- > testcases/kernel/mem/mtest06/mmap1.c | 8 +++++++- > 1 files changed, 7 insertions(+), 1 deletions(-) > > diff --git a/testcases/kernel/mem/mtest06/mmap1.c > b/testcases/kernel/mem/mtest06/mmap1.c > index cd11912..d671291 100644 > --- a/testcases/kernel/mem/mtest06/mmap1.c > +++ b/testcases/kernel/mem/mtest06/mmap1.c > @@ -352,6 +352,12 @@ read_mem(void *args) /* number of reads > performed */ > long *rmargs = args; /* local pointer to the arguments */ > long exit_val = 0; /* pthread exit value */ > > +retry: > + if (!map_address) { > + sched_yield(); > + goto retry; > + } > + > tst_resm(TINFO, "pid[%d] - read contents of memory %p %ld times", > getpid(), map_address, rmargs[2]); > if (verbose_print) > @@ -608,4 +614,4 @@ main(int argc, /* number of input parameters. > */ > close(fd); > }while (TRUE); > exit (0); > -} > \ No newline at end of file > +}
For the messy coding style of the pre code, I just be consistent with the others in this patch. Thanks -Wanlong Gao ------------------------------------------------------------------------------ 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
