eCryptfs: Unlock page in write_begin error path
authorTyler Hicks <tyhicks@linux.vnet.ibm.com>
Wed, 9 Mar 2011 17:49:13 +0000 (11:49 -0600)
committerBrad Figg <brad.figg@canonical.com>
Wed, 27 Apr 2011 18:40:31 +0000 (11:40 -0700)
BugLink: http://bugs.launchpad.net/bugs/761134

commit 50f198ae16ac66508d4b8d5a40967a8507ad19ee upstream.

Unlock the page in error path of ecryptfs_write_begin(). This may
happen, for example, if decryption fails while bring the page
up-to-date.

Signed-off-by: Tyler Hicks <tyhicks@linux.vnet.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>

fs/ecryptfs/mmap.c

index cc64fca..eb9d967 100644 (file)
@@ -374,6 +374,11 @@ static int ecryptfs_write_begin(struct file *file,
            && (pos != 0))
                zero_user(page, 0, PAGE_CACHE_SIZE);
 out:
+       if (unlikely(rc)) {
+               unlock_page(page);
+               page_cache_release(page);
+               *pagep = NULL;
+       }
        return rc;
 }