]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
PyModule: Fix memory leak in load_subclass_of
authorNitzan Mordechai <nmordech@redhat.com>
Sun, 9 Feb 2025 06:46:38 +0000 (06:46 +0000)
committerNitzan Mordechai <nmordech@redhat.com>
Wed, 7 May 2025 11:19:10 +0000 (11:19 +0000)
Fix missing Py_DECREF on mgr_module_type when the plugin module import fails.
This prevents a memory leak that occurs during subclass loading.

Signed-off-by: Nitzan Mordechai <nmordech@redhat.com>
src/mgr/PyModule.cc

index 4f996489ba0827b127cca6fc3a5be394efe3b8ee..e4b70956299094c88e577a2586f6f7c99c9315ed 100644 (file)
@@ -667,6 +667,7 @@ int PyModule::load_subclass_of(const char* base_class, PyObject** py_class)
     error_string = peek_pyerror();
     derr << "Module not found: '" << module_name << "'" << dendl;
     derr << handle_pyerror(true, module_name, "PyModule::load_subclass_of") << dendl;
+    Py_DECREF(mgr_module_type);
     return -ENOENT;
   }
   auto locals = PyModule_GetDict(plugin_module);