The undo function is one of the most useful options in Photoshop, but the number of previous actions you can undo is determined by a well-buried setting called History States. Increase the value of that figure to ensure you can undo unwanted edits.
In a post outlining changes you should make when setting up Photoshop, Helen Bradley points out that the default setting for History States is only 20 — not a very high number if you're making a lot of changes to an image and then decide to undo all those steps. You can increase the number (found under Preferences > Performance) to a maximum of 1000. That might be excessive (and will consume memory), but going above 20 definitely seems sensible.
Hit the link for more tweaks to improve Photoshop's performance and usability.
Five Photoshop setup tips [Project Woman]