if your Xperia m restart due to use of headphone during walkman,FM,camera then following is solution
1)update your phone to latest 15.1.C.1.17 ,this update is just 26mb when update via update via update app in your mobile
if this problem still not solved then do following
2) ask Sony service center to replace PCB(MAIN BOARD) this will definitely solve your problem