Overvoltage protection for electronic devices