On a characterization of linear compactness