]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd-mirror: fix segfault in snapshot replayer shutdown 41480/head
authorArthur Outhenin-Chalandre <arthur.outhenin-chalandre@cern.ch>
Fri, 21 May 2021 15:05:24 +0000 (17:05 +0200)
committerArthur Outhenin-Chalandre <arthur.outhenin-chalandre@cern.ch>
Fri, 21 May 2021 16:44:37 +0000 (18:44 +0200)
If an error arises in the init flow of the snapshot replayer and the
function returns before the call on `register_local_update_watcher`
the value of `m_update_watch_ctx` will not be initialized. Therefore,
on the shutdown phase, the replayer will try to free this pointer
and segfault.

This commit fixes this issue by setting `m_update_watch_ctx` to
`nullptr`.

Fixes: https://tracker.ceph.com/issues/50931
Signed-off-by: Arthur Outhenin-Chalandre <arthur.outhenin-chalandre@cern.ch>
src/tools/rbd_mirror/image_replayer/snapshot/Replayer.h

index 170d3c1d0cc81b34ae606345aa5bd63ecb05555c..c2c28171f87dcb63d79480e8f5f5553d004bb891 100644 (file)
@@ -211,7 +211,7 @@ private:
   int m_error_code = 0;
   std::string m_error_description;
 
-  C_UpdateWatchCtx* m_update_watch_ctx;
+  C_UpdateWatchCtx* m_update_watch_ctx = nullptr;
   uint64_t m_local_update_watcher_handle = 0;
   uint64_t m_remote_update_watcher_handle = 0;
   bool m_image_updated = false;