From: Gao Xiang
In case that new buffer allocation optimization logic is
potentially broken.
Signed-off-by: Gao Xiang
---
changes since v1:
- add a more check "used_before != cur->buffers.off % EROFS_BLKSIZ"
lib/cache.c | 8 +++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/lib/cache.c b/lib/cache.c
index 6ae2b202e67b..340dcdd76ce3 100644
--- a/lib/cache.c
+++ b/lib/cache.c
@@ -186,8 +186,14 @@ static int erofs_bfind_for_attach(int type, erofs_off_t
size,
mapped_list);
/* last mapped block can be expended, don't handle it here */
- if (cur == last_mapped_block)
+ if (list_next_entry(cur, list)->blkaddr == NULL_ADDR) {
+ DBG_BUGON(cur != last_mapped_block);
continue;
+ }
+
+ DBG_BUGON(cur->type != type);
+ DBG_BUGON(cur->blkaddr == NULL_ADDR);
+ DBG_BUGON(used_before != cur->buffers.off % EROFS_BLKSIZ);
ret = __erofs_battach(cur, NULL, size, alignsize,
required_ext + inline_ext, true);
--
2.24.0