If the carpet is only rippled at the ends, then cut off the loose fibers with scissors. If the problem is more widespread, then you will need to take up the entire section of carpet and reattach the edges with carpet tape. Make sure that the carpet is level before taping it down so that it does not bunch up. To make your carpet stay in it's place, it's critical that you choose the best double sided carpet tape from the store.