oomd: move TAKE_PTR to end of oomd_insert_cgroup_context()
authorAnita Zhang <the.anitazha@gmail.com>
Mon, 8 Mar 2021 18:35:31 +0000 (10:35 -0800)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 12 Mar 2021 16:35:57 +0000 (17:35 +0100)
Fixes #18926

(cherry picked from commit 45da27fa053898c1b94c175070a0dd63128875c9)

src/oom/oomd-util.c

index cec656f6faf418e830b50a6c300aa40f961bf01f..b17e506ce1967ff935c94ff2ebc9582dd1990798 100644 (file)
@@ -361,7 +361,7 @@ int oomd_system_context_acquire(const char *proc_swaps_path, OomdSystemContext *
 
 int oomd_insert_cgroup_context(Hashmap *old_h, Hashmap *new_h, const char *path) {
         _cleanup_(oomd_cgroup_context_freep) OomdCGroupContext *curr_ctx = NULL;
-        OomdCGroupContext *old_ctx, *ctx;
+        OomdCGroupContext *old_ctx;
         int r;
 
         assert(new_h);
@@ -378,11 +378,11 @@ int oomd_insert_cgroup_context(Hashmap *old_h, Hashmap *new_h, const char *path)
                 curr_ctx->last_hit_mem_pressure_limit = old_ctx->last_hit_mem_pressure_limit;
         }
 
-        ctx = TAKE_PTR(curr_ctx);
-        r = hashmap_put(new_h, ctx->path, ctx);
+        r = hashmap_put(new_h, curr_ctx->path, curr_ctx);
         if (r < 0)
                 return r;
 
+        TAKE_PTR(curr_ctx);
         return 0;
 }