Generalized modified gravity models: the stability issue