mirror of
https://github.com/torvalds/linux.git
synced 2026-05-26 08:02:27 +02:00
bcachefs: Fix lookup_inode_for_snapshot()
This fixes a use-after-free. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
6b20d746ad
commit
20e6d9a8d4
|
|
@ -682,6 +682,7 @@ lookup_inode_for_snapshot(struct bch_fs *c, struct inode_walker *w,
|
|||
|
||||
if (snapshot != i->snapshot && !is_whiteout) {
|
||||
struct inode_walker_entry new = *i;
|
||||
size_t pos;
|
||||
int ret;
|
||||
|
||||
new.snapshot = snapshot;
|
||||
|
|
@ -693,9 +694,12 @@ lookup_inode_for_snapshot(struct bch_fs *c, struct inode_walker *w,
|
|||
while (i > w->inodes.data && i[-1].snapshot > snapshot)
|
||||
--i;
|
||||
|
||||
ret = darray_insert_item(&w->inodes, i - w->inodes.data, new);
|
||||
pos = i - w->inodes.data;
|
||||
ret = darray_insert_item(&w->inodes, pos, new);
|
||||
if (ret)
|
||||
return ERR_PTR(ret);
|
||||
|
||||
i = w->inodes.data + pos;
|
||||
}
|
||||
|
||||
return i;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user