ext4 crypto: fix memory leak in ext4_bio_write_page()
authorTheodore Ts'o <tytso@mit.edu>
Sat, 3 Oct 2015 03:54:58 +0000 (23:54 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 15 Dec 2015 05:25:42 +0000 (21:25 -0800)
commit34a6ac6aabb893b29b286fad62c86f5bd2c23bbb
tree6b4fac0cd8c05a7696db17ec06888ac0c5d39fe0
parent587de47c5adfd7a13d2f239bd7ad88a31be2b21c
ext4 crypto: fix memory leak in ext4_bio_write_page()

commit 937d7b84dca58f2565715f2c8e52f14c3d65fb22 upstream.

There are times when ext4_bio_write_page() is called even though we
don't actually need to do any I/O.  This happens when ext4_writepage()
gets called by the jbd2 commit path when an inode needs to force its
pages written out in order to provide data=ordered guarantees --- and
a page is backed by an unwritten (e.g., uninitialized) block on disk,
or if delayed allocation means the page's backing store hasn't been
allocated yet.  In that case, we need to skip the call to
ext4_encrypt_page(), since in addition to wasting CPU, it leads to a
bounce page and an ext4 crypto context getting leaked.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/ext4/page-io.c