{
        struct xfs_owner_info           oinfo;
        struct xfs_mount                *mp = tp->t_mountp;
-       struct xfs_btree_cur            *rcur;
+       struct xfs_btree_cur            *rcur = *pcur;
        struct xfs_buf                  *agbp = NULL;
        xfs_agblock_t                   bno;
        bool                            unwritten;
         * If we haven't gotten a cursor or the cursor AG doesn't match
         * the startblock, get one now.
         */
-       rcur = *pcur;
        if (rcur != NULL && rcur->bc_ag.pag != ri->ri_pag) {
                xfs_btree_del_cursor(rcur, 0);
                rcur = NULL;
                        return -EFSCORRUPTED;
                }
 
-               rcur = xfs_rmapbt_init_cursor(mp, tp, agbp, ri->ri_pag);
+               *pcur = rcur = xfs_rmapbt_init_cursor(mp, tp, agbp, ri->ri_pag);
        }
-       *pcur = rcur;
 
        xfs_rmap_ino_owner(&oinfo, ri->ri_owner, ri->ri_whichfork,
                        ri->ri_bmap.br_startoff);