If the washer overfills, it may be something as simple as a detached or broken air hose on the pressure switch. The following link explains:http://www.fixya.com/support/r762094-washer_overflows
The pressure switch on top loaders is located behind the load level selector knob on the operator console. The pressure switch on front loaders will be located inside the cabinet, usually mounted along the back interior wall. In the case of certain Maytag front loaders, the pressure switch is actually located under the tub. The principles of operation on all of them is the same, though. They all have an electrical connection and an air hose that detects the pressure from the tub as the water level rises.
If the pressure switch is not able to detect the water level properly, it will not shut off and the washer will never begin the wash cycle. Instead, you get a tub overflowing on your laundry room floor.
Read through the link provided and let me know if you have any questions. I hope this helps you.
NOTE: Another source of an overflow could be the water inlet valve. This is usually a slow fill fill that you find when the washer is sitting idle over night. A quick test to determine the source of the problem is to unplug the washer. If the water stops - pressure switch. If the water continues to fill - water inlet valve.
If you have questions, please let me know. I hope this helps you.