async_set_result() is the only way the async completion callback can be called. If the async were never queued (e.g. if it is a request async, and it failed in a very early stage), it could be destroyed without its completion callback ever being called. This leads to memory leak.
Fix this by calling the completion_callback if it was not already called and then set to NULL.
Signed-off-by: Jinoh Kang jinoh.kang.kr@gmail.com ---
Notes: v4 -> v5: new patch v5 -> v6: no changes
server/async.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/server/async.c b/server/async.c index d49fb8b7c04..3e5ca7ccf8c 100644 --- a/server/async.c +++ b/server/async.c @@ -144,6 +144,10 @@ static void async_destroy( struct object *obj ) struct async *async = (struct async *)obj; assert( obj->ops == &async_ops );
+ if (async->completion_callback) + async->completion_callback( async->completion_callback_private ); + async->completion_callback = NULL; + list_remove( &async->process_entry );
if (async->queue)