On the masses of mesons and baryons in potential models