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)
committerIan Chang <ianc@nvidia.com>
Wed, 1 Jun 2016 05:00:05 +0000 (13:00 +0800)
commit18f63e296ce6da80bbea91d20210faf96b31a6ce
treec11b634093c5286e969a932f1a4bc9946c6fe68e
parentc4a6d15f515d1e0ac1235786ca888d77c2e2de2b
ext4 crypto: fix memory leak in ext4_bio_write_page()

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.

Change-Id: Icd2123808fd7372c11e6f9e17849e242837d729d
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: "Theodore Ts'o" <tytso@google.com>
Cc: stable@vger.kernel.org
Reviewed-on: http://git-master/r/1154510
Reviewed-by: Ian Chang <ianc@nvidia.com>
Tested-by: Ian Chang <ianc@nvidia.com>
fs/ext4/page-io.c