Let $mathfrak{a}$ be an ideal of a noetherian (not necessarily local) ring $R$ and $M$ an $R$-module with $mathrm{Supp}_RMsubseteqmathrm{V}(mathfrak{a})$. We show that if $mathrm{dim}_RMleq2$, then $M$ is $mathfrak{a}$-cofinite if and only if $mathrm{Ext}^i_R(R/mathfrak{a},M)$ are finitely generated for all $ileq 2$, which generalizes one of the main results in [Algebr. Represent. Theory 18 (2015) 369--379]. Some new results concerning cofiniteness of local cohomology modules $mathrm{H}^i_mathfrak{a}(M)$ for any finitely generated $R$-module $M$ are obtained.