Conventional error correcting codes (ECC) scheme for caches is based on fixed mapping between cache words and ECC check bits, and fixed ECC word granularity, which leads to inefficient usage of ECC check bits. In contrast, we propose to use the ECC check bits flexibly for low-cost error protections of L2 caches. Our ECC scheme works at word level while the conventional ECC scheme works at cache line or set level; Our scheme protects only dirty words with ECC check bits via flexible mapping between them. In addition, our scheme utilizes variable ECC word granularities; Dirty words that are unlikely to be modified further before evicted are protected together with larger ECC word granularity. Our flexible ECC management reduces DRAM and data bus energy overheads by 28% and 45% on average, respectively, with the same area overhead as a previously proposed competitive scheme.