1. A method performed by a memory controller, comprising: controlling access to system memory, the accesses including memory writes and memory reads; monitoring patterns of accesses to the system memory; detecting a return address for a function call in the system memory; and preventing the return address from being overwritten unless the memory controller determines it is safe.