A simple series Schottky diode will protect against reverse polarity.
Typically you would have polarized or distinctly separate connector types to ensure you don't use the wrong supply, but assuming you have not taken that basic design step, you need to decide what action to take on overvoltage.
- Blow a fuse, which seems rather drastic since this then means manual intervention to fix it. You may not be aware of the fuse blowing (if it's in a holder for example), so your first indication of a problem is when the fan does not start when you turn the power on. This may be long after you mis-connected the cable. There are endless circuits to provide this type of brute force protection. For example:
- Provide inline active turnoff protection with a FET for example (Google for overvoltage Load Switch ...there are many modern examples). For silent protection such as this, should you provide an indicator (for both reverse voltage and over voltage errors) for faults. An example here is the Fairchild/ONSemi FPF2281 which even provide an indicator port for an MCU or LED:
Note: You still need to use a series diode for reverse voltage protection.
Of course you should consider:
- Design your system with unique power connections so you cannot make this very basic mistake. You should never be able to mis-connect your fan in any sensible design.