There is no problem if you have signed a trademark transfer or licensing contract before your trademark registration is declared invalid. However, after it is declared invalid, the previously signed contract will have no legal effect. Yes, the contract is invalid and needs to be revoked.
So, when buying or selling a trademark, you should pay attention to whether it has been successfully registered, or whether it may be controversial. If so, you should pay attention to it.