Skip to content

Commit

Permalink
[process] Hold reference to process during call to step()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
mcb30 committed Jun 15, 2010
1 parent 1798e04 commit 068ef5f
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/core/process.c
Expand Up @@ -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;
}
}
Expand Down

0 comments on commit 068ef5f

Please sign in to comment.