It’s even more straightforward that you think it is; you just need to set the material of that object equal to ‘m’.
gameObject.GetComponent<MeshRenderer>().material = m;
If you ever need to refer to the GameObject that the script is running on, just use ‘gameObject.’
GetComponent is your friend as far as finding/using the components attached to that object.