Are there any scratches on the lense or any dust under it? If yes, remove the dust and get a new backcover. You can get one here: http://m.ebay.com/itm/New-OEM-Apple-iPhone-4-AT-T-GSM-Black-Back-Cover-Glass-Battery-Door-/151679902092?nav=SEARCH If that is not the case the camera itself is bad and you will replace that. You can also get that on ebay. It also might be both.
Shut it down. Once it is done powering off, hold the home button and while you press the homebutton you plug it in to your computer. You are now in recovery mode. Open itunes and restore it. That will erase all data including the passcode! Hope this helps!
This is a very common problem with the iphone 4s. To fix it you need to take apart your iphone and heat the black chip located on top right corner of the motherboard with a hairdryer for a few minutes. This is only a temporary fix that will last for a few months only. After that you need to do it again. To permanently fix it the chip or the whole motherboard need to be replaced.