IANAP, but as far as I know it is true only if m is the relativistic mass which apparently is an obsolete and confusing concept which is not taught anymore (according to Wikipedia Einstein himself disliked it). Otherwise the formula only holds at rest.