diff options
author | Michael Brown <mcb30@ipxe.org> | 2008-06-13 03:39:22 +0100 |
---|---|---|
committer | Michael Brown <mcb30@ipxe.org> | 2010-06-15 16:26:28 +0100 |
commit | 068ef5f72d6acd7ebdd3ec4065c9e9aeb6ff9b1b (patch) | |
tree | c3e9e4717e346088eeac2bbd61d8b2dda8945336 /src/core/process.c | |
parent | 1798e04ebbb4f86ef1b1ba1432f835482b1543b2 (diff) | |
download | ipxe-068ef5f72d6acd7ebdd3ec4065c9e9aeb6ff9b1b.tar.gz |
[process] Hold reference to process during call to step()
It is conceivable that the process may terminate during the execution
of step(). If nothing else holds a reference to the containing
object, this would cause the object to be freed prior to returning
from step().
Add a ref_get()/ref_put() around the call to ->step() to prevent this
from happening.
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/core/process.c')
-rw-r--r-- | src/core/process.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/core/process.c b/src/core/process.c index 940e3b878..d46737b04 100644 --- a/src/core/process.c +++ b/src/core/process.c @@ -82,9 +82,11 @@ void step ( void ) { list_for_each_entry ( process, &run_queue, list ) { list_del ( &process->list ); list_add_tail ( &process->list, &run_queue ); + ref_get ( process->refcnt ); /* Inhibit destruction mid-step */ DBGC2 ( process, "PROCESS %p executing\n", process ); process->step ( process ); DBGC2 ( process, "PROCESS %p finished executing\n", process ); + ref_put ( process->refcnt ); /* Allow destruction */ break; } } |