]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
bcachefs: Fix use after free in bch2_check_fix_ptrs()
authorKent Overstreet <kent.overstreet@linux.dev>
Tue, 26 Mar 2024 21:38:22 +0000 (17:38 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Mon, 1 Apr 2024 00:36:11 +0000 (20:36 -0400)
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/btree_gc.c

index 6d32ac9be2438ffcc8beb651def55a31257c24dd..26e51af9acdcf0845fed36d65ba7cf946234b0d1 100644 (file)
@@ -691,12 +691,6 @@ found:
                        }
                }
 
-               ret = bch2_journal_key_insert_take(c, btree_id, level, new);
-               if (ret) {
-                       kfree(new);
-                       goto err;
-               }
-
                if (level)
                        bch2_btree_node_update_key_early(trans, btree_id, level - 1, *k, new);
 
@@ -710,6 +704,12 @@ found:
                        bch_info(c, "new key %s", buf.buf);
                }
 
+               ret = bch2_journal_key_insert_take(c, btree_id, level, new);
+               if (ret) {
+                       kfree(new);
+                       goto err;
+               }
+
                *k = bkey_i_to_s_c(new);
        }
 err: