Einstein not only "did fine" but was extremely precocious. From the wiki entry:
- - -
Einstein excelled at math and physics from a young age, reaching a mathematical level years ahead of his peers. The 12-year-old Einstein taught himself algebra and Euclidean geometry over a single summer.[28] Einstein also independently discovered his own original proof of the Pythagorean theorem aged 12.[29] A family tutor Max Talmud says that after he had given the 12-year-old Einstein a geometry textbook, after a short time "[Einstein] had worked through the whole book. He thereupon devoted himself to higher mathematics... Soon the flight of his mathematical genius was so high I could not follow."[30] His passion for geometry and algebra led the 12-year-old to become convinced that nature could be understood as a "mathematical structure".[30] Einstein started teaching himself calculus at 12, and as a 14-year-old he says he had "mastered integral and differential calculus".[31]
- - -
At age 16, he tried to skip the last two years of gymnasium and directly go to University -- to what is now known as ETH, a fantastically rigorous and selective research university -- but failed the entrance examination. He excelled at the math and physics portions, but of course did not pass in the humanities questions covering material he never studied. This is what caused many myths about him getting kicked out of school, or failing to graduate, etc. In reality, this just means he needed to attend a gymnasium to get the required secondary education in the humanities that he tried to skip.
Starting with university, he did focus on physics, so compared to many theoretical physicists who had the equivalent of a dual math/physics PhD, Einstein's PhD was more physics focused, and for this reason he is not considered as strong of a mathematician as he is a physicist, but this doesn't mean he wasn't good at math, or that he received failing grades, or that he dropped out, etc.
I'm not an expert by any means, but my understanding is that Dirac was a highly accomplished mathematician, and of course Hilbert made his name in mathematics before moving to study physics.
Dirac came from a later generation than Einstein. For example during Einstein's annus mirabilis (1905) I doubt very many physicists knew of tensor calculus considering it was only developed a decade beforehand. During that time the mathematics physicists learnt was very much the traditional topics of analysis: series expansions, special functions, integral equations, calculus of variations, quadratic forms and of course partial differential equations. Hilbert himself actually wrote a textbook with Richard Courant covering these topics: Methods of Mathematical Physics. As such I don't really think many physicists of Einstein's generation knew lots of mathematics simply because it wasn't taught at the time. In the decades since physicists gradually has generally become more "mathematised" so to speak. In Dirac's generation tensor calculus and group representation theory became important, than in general abstract algebra and functional analysis, then as differential geometry became more well developed that gets taught and closer to the modern day you can find top theoretical physics students learning all sorts of abstract mathematics like algebraic topology.
But relative to other theoretical physicists he was not the strongest mathematician.