Java Language Specification says under
17.5 Rules about Locks
Only one thread at a time is permitted to lay claim to a lock, and moreover a thread may acquire the same lock multiple times and doesn't relinquish ownership of it until a matching number of unlock actions have been performed
Although I cannot think of a situation where you would need the lock more than once, it is perfectly legal. For instance, if you have two synchronized methods A and B and if A calls B before returing the control, the sequence will make the thread acquire two locks on the same object. Although IMO this is a very bad design.
The concept of deadlock and race condition is slightly different. So far we have been talking about a single thread scenario. Deadlocks and/or race conditions happen when more than one thread is in the playground, each thread contending for the lock. As for your example is concerned, it is quite harmless because by the time the inner synchronized block is executed, the thread already has obtained the lock on the object.
Hope that helps.