In most cases a good level hammer blow and a nice dimple will cure the problem. then apply some spackle over the area and you are off.
If the nail is real loose, then carefully pull it out and install a long screw in the same spot and tighten it down. If the hole is wallered out, then spackle it and screw it down 3 inches up or down from that spot.
Most cases these nails just need persuasion to go back and it is fine.