We study the higher regularity of solutions and free boundaries in the Alt–Phillips problem \(\Delta u=u^{\gamma -1},\) with \(\gamma \in (0,1).\) Our main results imply that, once free boundaries are \(C^{1,\alpha },\) then they are \(C^\infty .\) In addition \(u/d^{\frac{2}{2-\gamma }}\) and \(u^{\frac{2-\gamma }{2}}\) are \(C^\infty \) too. In order to achieve this, we need to establish fine regularity estimates for solutions of linear equations with boundary-singular Hardy potentials \(-\Delta v = \kappa v/d^2\) in \(\Omega ,\) where d is the distance to the boundary and \(\kappa \le \frac{1}{4}.\) Interestingly, we need to include even the critical constant \(\kappa =\frac{1}{4},\) which corresponds to \(\gamma =\frac{2}{3}.\)