A new method for laser-frequency stabilization by controlling the pulse setup time is presented. The frequency-stabilization system monitors the pulse setup time continuously, and controls it by adjusting the cavity length. Laser frequency is stabilized to the center of the gain curve when the setup time is the shortest. The system is used to stabilize a radio-frequency-excited waveguide CO2 laser tuned by grating, and the shift of laser frequency is estimated to be less than §25 MHz for an extended period. The system has the advantages of compact structure, small volume, and low cost. It can be applied for frequency stabilization of other kinds of pulsed lasers with adjustable cavity.