The problem of the linear stability of internal magnetohydrodynamic modes in a cylindrical plasma with a sheared longitudinal flow is addressed. A Newcomb-like equation describing the perturbation is derived and exactly solved for a class of analytic profiles for rotational transform, equilibrium flow and pressure. A dispersion relation for ideal modes is then derived and analysed for different limits of the poloidal mode number (viz. m = 1, and ). In the resistive case, a simple and exact expression for the tearing stability index is derived using the same class of equilibrium profiles. It is found that a small flow shear has a destabilising effect, while if the flow shear is dominant over the magnetic shear the tearing mode is stabilised. Implications on the stability of the m = 1 resistive mode are also discussed.