It is highly unlikely that you would have to give the car back if financing fell through. In most cases, the dealership will simply cancel the deal. However, there are a few exceptions. For example, if you signed a contract that specifically stated that you would return the car if financing fell through, then you may be obligated to do so. Additionally, if you already took possession of the car and drove it off the lot, the dealer may be able to charge you a "restocking fee". This fee is usually a percentage of the purchase price, and it can vary from dealer to dealer.
To protect yourself, it's important to read and understand all of the terms and conditions of the purchase contract before you sign it. If you have any questions, be sure to ask the dealer for clarification.