bh = nilfs_grab_buffer(inode, btnc, blocknr, BIT(BH_NILFS_Node));
        if (unlikely(!bh))
-               return NULL;
+               return ERR_PTR(-ENOMEM);
 
        if (unlikely(buffer_mapped(bh) || buffer_uptodate(bh) ||
                     buffer_dirty(bh))) {
-               brelse(bh);
-               BUG();
+               /*
+                * The block buffer at the specified new address was already
+                * in use.  This can happen if it is a virtual block number
+                * and has been reallocated due to corruption of the bitmap
+                * used to manage its allocation state (if not, the buffer
+                * clearing of an abandoned b-tree node is missing somewhere).
+                */
+               nilfs_error(inode->i_sb,
+                           "state inconsistency probably due to duplicate use of b-tree node block address %llu (ino=%lu)",
+                           (unsigned long long)blocknr, inode->i_ino);
+               goto failed;
        }
        memset(bh->b_data, 0, i_blocksize(inode));
        bh->b_bdev = inode->i_sb->s_bdev;
        folio_unlock(bh->b_folio);
        folio_put(bh->b_folio);
        return bh;
+
+failed:
+       folio_unlock(bh->b_folio);
+       folio_put(bh->b_folio);
+       brelse(bh);
+       return ERR_PTR(-EIO);
 }
 
 int nilfs_btnode_submit_block(struct address_space *btnc, __u64 blocknr,
        }
 
        nbh = nilfs_btnode_create_block(btnc, newkey);
-       if (!nbh)
-               return -ENOMEM;
+       if (IS_ERR(nbh))
+               return PTR_ERR(nbh);
 
        BUG_ON(nbh == obh);
        ctxt->newbh = nbh;