don't worry !! clean your phone regularly and restart it once in a week... the problem gets done in a few weeks. i suggest to use normal brightness and no games for continuous 3,4hours
check if the current produced in your house is stable or not. next , use only Samsung charger provided to your phone.if the overheating is in the bottom side, it could be a battery fault
best way is to sign in to your Samsung account and the next step it shows... to choose back up process.. back up with Samsung account so that u can transfer all the information when u buy a new Samsung mobile .fortunately mine is also m40 but it doe...