When I execute the result is "Segmentation Fault" when reached the "Line M3"

My objetive is pass to m pointer the address of memory allocated by the function teste.
If I do the function return the pointer, all work fine. Is possible make this passing the pointer by argument, like above code?