It is expected that a totally invariant divisor of a non-isomorphic endomorphism of the complex projective space is a union of hyperplanes. In this paper, we compute an upper bound for the degree of such a divisor. As a consequence, we prove the linearity of totally invariant divisors with isolated singularities.