mirror of
https://github.com/torvalds/linux.git
synced 2024-09-20 15:03:04 +00: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 @@ found:
|
|||
|
||||
if (snapshot != i->snapshot && !is_whiteout) {
|
||||
struct inode_walker_entry new = *i;
|
||||
size_t pos;
|
||||
int ret;
|
||||
|
||||
new.snapshot = snapshot;
|
||||
|
@ -693,9 +694,12 @@ found:
|
|||
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