
As you suggest, this is a remote possibility, especially for modern mathematics that is based upon the Zermelo-Frankel set theory expanded by the Axiom of Choice. However, if an inconsistency were discovered, mathematicians would look for a subset of the current axioms to determine whether that would eliminate the inconsistency.
Once the troublesome axiom were found (perhaps, the Axiom of Choice) all of the mathematical theorems that did not require that axiom would be declared as valid. Weaker versions of the deleted axiom might be tested to see if they removed the inconsistency.
In a worst case scenario, mathematical theorems would be classified into subsystems with specific sets of axioms for different branches of mathematics. For example, we currently have many theorems that are true only if the Riemann Hypothesis is true. Another set of theorems can be deduced, based on the assumption that the Riemann Hypothesis false.
Since the Continuum Hypothesis is undecidable, we could conceivably have two subsets of mathematical theorems based on whether or not the Continuum Hypothesis is true.
The good news is that virtually all the mathematical theorems that we use in science and engineering lead to accurate results. This gives us confidence that these are universal laws of logic and therefore consistent. However, when dealing with infinities as in transfinite numbers, empirical evidence is not available and we have to hope that our abstractions don’t yield contradictions. The discoveries on non-Euclidean geometries and Gödel’s incompleteness theorems have taught us that we must be extremely careful in formulating our axioms, but even when we find a “glitch” in the system, we can re-structure our knowledge and build a more robust system. As artificial intelligence continues to evolve, we may find more powerful tools for checking the consistency and scope of mathematics based on specific axiomatic systems.