]> www.infradead.org Git - users/sagi/libnvme.git/commitdiff
Python: Fix crash during garbage collection
authorMartin Belanger <martin.belanger@dell.com>
Tue, 2 May 2023 18:22:46 +0000 (14:22 -0400)
committerDaniel Wagner <wagi@monom.org>
Thu, 4 May 2023 06:38:10 +0000 (08:38 +0200)
Same fix as commit d2a5491d1681ead6d8983d0bf6ecae937ab9f317

Prevent Garbage Collector (GC) from deleting host and root objects
before all controller objects under that root/host have been GCed.
This time, it's the init() method that needed the fix. Previously
we had only fixed the connect() method.

Signed-off-by: Martin Belanger <martin.belanger@dell.com>
libnvme/nvme.i

index 9f97a4dcbd28adb52230fa354dff79abfa1f0308..8b461e6e9b86a1eafe920253910aba7195e8aab9 100644 (file)
@@ -612,7 +612,9 @@ struct nvme_ns {
 
 %pythonappend nvme_ctrl::connect(struct nvme_host *h,
                                 struct nvme_fabrics_config *cfg) {
-    self.__parent = h  # Keep a reference to parent to ensure garbage collection happens in the right order}
+    self.__host = h  # Keep a reference to parent to ensure ctrl obj gets GCed before host}
+%pythonappend nvme_ctrl::init(struct nvme_host *h, int instance) {
+    self.__host = h  # Keep a reference to parent to ensure ctrl obj gets GCed before host}
 %extend nvme_ctrl {
        nvme_ctrl(struct nvme_root *r,
                  const char *subsysnqn,