Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

bcachefs: handle failed data_update_init cleanup

data_update_init allocates several resources, but we forget to clean
these up when it fails.

Signed-off-by: Daniel Hill <daniel@gluo.nz>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>

authored by

Daniel Hill and committed by
Kent Overstreet
f3a37e76 71fe1465

+9 -1
+9 -1
fs/bcachefs/data_update.c
··· 469 469 ? 0 470 470 : BCH_DISK_RESERVATION_NOFAIL); 471 471 if (ret) 472 - return ret; 472 + goto err; 473 473 } 474 474 475 475 m->op.nr_replicas = m->op.nr_replicas_required = ··· 481 481 if (bkey_extent_is_unwritten(k)) 482 482 return -BCH_ERR_unwritten_extent_update; 483 483 return 0; 484 + err: 485 + bkey_for_each_ptr_decode(k.k, ptrs, p, entry) 486 + bch2_bucket_nocow_unlock(&c->nocow_locks, 487 + PTR_BUCKET_POS(c, &p.ptr), 0); 488 + 489 + bch2_bkey_buf_exit(&m->k, c); 490 + bch2_bio_free_pages_pool(c, &m->op.wbio.bio); 491 + return ret; 484 492 } 485 493 486 494 void bch2_data_update_opts_normalize(struct bkey_s_c k, struct data_update_opts *opts)