target/riscv: Free registers to avoid memory leak