===MODEL PATCH ===
--- a/fs/nilfs2/btree.c
+++ b/fs/nilfs2/btree.c
@@ -1232,6 +1232,7 @@ static int nilfs_btree_node_lookup(const struct nilfs_btree_node *node,
 		} else if (nkey < key) {
 			low = index + 1;
 			s = -1;
+			if (low > high) index = high + 1;  // Adjust index to prevent out-of-bound access
 		} else {
 			high = index - 1;
 			s = 1;

===ORIGINAL PATCH ===
diff --git a/fs/nilfs2/btree.c b/fs/nilfs2/btree.c
index b9d15c3df3cc..40ce92a332fe 100644
--- a/fs/nilfs2/btree.c
+++ b/fs/nilfs2/btree.c
@@ -480,9 +480,18 @@ static int __nilfs_btree_get_block(const struct nilfs_bmap *btree, __u64 ptr,
 	ret = nilfs_btnode_submit_block(btnc, ptr, 0, REQ_OP_READ, &bh,
 					&submit_ptr);
 	if (ret) {
-		if (ret != -EEXIST)
-			return ret;
-		goto out_check;
+		if (likely(ret == -EEXIST))
+			goto out_check;
+		if (ret == -ENOENT) {
+			/*
+			 * Block address translation failed due to invalid
+			 * value of 'ptr'.  In this case, return internal code
+			 * -EINVAL (broken bmap) to notify bmap layer of fatal
+			 * metadata corruption.
+			 */
+			ret = -EINVAL;
+		}
+		return ret;
 	}
 
 	if (ra) {

