Commit 46e4bb1c authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: Fix a use after free

op->end_io may free the op struct
Signed-off-by: default avatarKent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent e731d466
...@@ -516,12 +516,13 @@ static void bch2_write_done(struct closure *cl) ...@@ -516,12 +516,13 @@ static void bch2_write_done(struct closure *cl)
bch2_time_stats_update(&c->times[BCH_TIME_data_write], op->start_time); bch2_time_stats_update(&c->times[BCH_TIME_data_write], op->start_time);
if (op->end_io) if (op->end_io) {
EBUG_ON(cl->parent);
closure_debug_destroy(cl);
op->end_io(op); op->end_io(op);
if (cl->parent) } else {
closure_return(cl); closure_return(cl);
else }
closure_debug_destroy(cl);
} }
/** /**
...@@ -1234,12 +1235,14 @@ void bch2_write(struct closure *cl) ...@@ -1234,12 +1235,14 @@ void bch2_write(struct closure *cl)
err: err:
if (!(op->flags & BCH_WRITE_NOPUT_RESERVATION)) if (!(op->flags & BCH_WRITE_NOPUT_RESERVATION))
bch2_disk_reservation_put(c, &op->res); bch2_disk_reservation_put(c, &op->res);
if (op->end_io)
if (op->end_io) {
EBUG_ON(cl->parent);
closure_debug_destroy(cl);
op->end_io(op); op->end_io(op);
if (cl->parent) } else {
closure_return(cl); closure_return(cl);
else }
closure_debug_destroy(cl);
} }
/* Cache promotion on read */ /* Cache promotion on read */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment