We present a sufficient condition for asymptotic stability of a switched linear system in terms of the Lie algebra generated by the individual matrices. Namely, if this Lie algebra is solvable, then the switched system is exponentially stable for arbitrary switching. In fact, we show that any family of linear systems satisfying this condition possesses a quadratic common Lyapunov function. We also discuss the implications of this result for switched nonlinear systems.