]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librados: rados_ioctx_destroy check for initialized ioctx 47165/head
authorNitzanMordhai <nmordech@redhat.com>
Tue, 19 Jul 2022 08:35:32 +0000 (08:35 +0000)
committerNitzanMordhai <nmordech@redhat.com>
Tue, 19 Jul 2022 08:35:43 +0000 (08:35 +0000)
If rados_ioctx_destroy called with un-initilized ioctx we will hit segmented fault
checking ioctx before calling put will prevent that.

Fixes: https://tracker.ceph.com/issues/55001
Signed-off-by: Nitzan Mordechai <nmordec@redhat.com>
src/librados/librados_c.cc

index ee516d8ff668187c65516a344e4852970a3b16c5..f09e86b2e9609fb0af141fcc58d5376a4f39b6e8 100644 (file)
@@ -1174,7 +1174,9 @@ extern "C" void LIBRADOS_C_API_DEFAULT_F(rados_ioctx_destroy)(rados_ioctx_t io)
 {
   tracepoint(librados, rados_ioctx_destroy_enter, io);
   librados::IoCtxImpl *ctx = (librados::IoCtxImpl *)io;
-  ctx->put();
+  if (ctx) {
+    ctx->put();
+  }
   tracepoint(librados, rados_ioctx_destroy_exit);
 }
 LIBRADOS_C_API_BASE_DEFAULT(rados_ioctx_destroy);