persistent_ram: Fix buffer size clamping during writes