No, it is not right, since you cannot consider g(x,y) when (*) is not exact.
You could argue as follows.
When the equation has a solution g(x,y)=c, the integrating factor is 1.
Conversely, suppose that m is an integrating factor.
Then mMdx+mNdy is exact, and so there exists G(x,y) such that...