Why does my Linksys WRT54GS keep losing its memory?
There is no battery in this device. Likely the NVRAM isn't working correctly or it was relying on a capacitor which doesn't last all night. Personally I would first check for firmware upgrades on the Linksys by Cisco site (silly name) incase this firmware isn't correctly using NVRAM.
IMO you can't do anything to fix this problem other than asking the manufacturer for a maintenance or buy another router.
A workaround of this problem is to export your router settings, and import them once they're lost.