flexnbd status: Avoid a possible NULL dereference reading migration status

While the mirror mutex is taken, the mirroring can be abandoned and serve->mirror
set to NULL, so we need to lock around reading information from serve->mirror
This commit is contained in:
nick
2013-07-08 13:32:14 +01:00
parent dee0bb27d6
commit b29ef6d4de
3 changed files with 83 additions and 38 deletions

View File

@@ -11,12 +11,16 @@ struct status * status_create( struct server * serve )
status->pid = getpid();
status->size = serve->size;
status->has_control = serve->success;
status->is_mirroring = NULL != serve->mirror;
server_lock_start_mirror( serve );
status->is_mirroring = NULL != serve->mirror;
if ( status->is_mirroring ) {
status->migration_pass = serve->mirror->pass;
}
server_unlock_start_mirror( serve );
return status;
}