mirror: Fix access of uninitialised fields during start
authorKevin Wolf <kwolf@redhat.com>
Fri, 3 Feb 2023 15:21:41 +0000 (16:21 +0100)
committerKevin Wolf <kwolf@redhat.com>
Thu, 23 Feb 2023 18:48:57 +0000 (19:48 +0100)
commit32125b14606a454ed109ea6d9da32c747e94926f
tree7b79b418c3e67fa454905fc95a8b74cbe0c2e407
parent10e5d70787b0bcb8c4449ee2fa6a0154d4138186
mirror: Fix access of uninitialised fields during start

bdrv_mirror_top_pwritev() accesses the job object when active mirroring
is enabled. It disables this code during early initialisation while
s->job isn't set yet.

However, s->job is still set way too early when the job object isn't
fully initialised. For example, &s->ops_in_flight isn't initialised yet
and the in_flight bitmap doesn't exist yet. This causes crashes when a
write request comes in too early.

Move the assignment of s->job to when the mirror job is actually fully
initialised to make sure that the mirror_top driver doesn't access it
too early.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Message-Id: <20230203152202.49054-3-kwolf@redhat.com>
Reviewed-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block/mirror.c