which version of garageband you using?
I have 08 so I'll comment assuming that's what you're using. Press the repeat button (to the right of the play/fd/rw buttons). Once turned on, you'll see a yellow bar appear above your track. Adjust the length of it to match the music. If it's too long, you'll get blank spots.