Thermodynamic stability of superconducting magnetic states