I had this problem with my M&P 15-22. I made a tool up to remove the barrel. Once the barrel was removed the barrel extension is pinned with 2 roll pins. One of the pins tensions the ejector by tapping it further into the hole.
Unfortunately mine was so loose that further investigation was...