]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
ecryptfs: test lower_file pointer when lower_file_mutex is locked
authorRoberto Sassu <roberto.sassu@polito.it>
Wed, 3 Nov 2010 10:11:28 +0000 (11:11 +0100)
committerTyler Hicks <tyhicks@linux.vnet.ibm.com>
Mon, 17 Jan 2011 17:24:42 +0000 (11:24 -0600)
This patch prevents the lower_file pointer in the 'ecryptfs_inode_info'
structure to be checked when the mutex 'lower_file_mutex' is not locked.

Signed-off-by: Roberto Sassu <roberto.sassu@polito.it>
Signed-off-by: Tyler Hicks <tyhicks@linux.vnet.ibm.com>
fs/ecryptfs/file.c
fs/ecryptfs/inode.c

index 679817e82484e1fd2964a07730b110c4e79c6100..99259f850e586c9dabd0f0de87d1205825b3f33e 100644 (file)
@@ -191,15 +191,13 @@ static int ecryptfs_open(struct inode *inode, struct file *file)
                                      | ECRYPTFS_ENCRYPTED);
        }
        mutex_unlock(&crypt_stat->cs_mutex);
-       if (!ecryptfs_inode_to_private(inode)->lower_file) {
-               rc = ecryptfs_init_persistent_file(ecryptfs_dentry);
-               if (rc) {
-                       printk(KERN_ERR "%s: Error attempting to initialize "
-                              "the persistent file for the dentry with name "
-                              "[%s]; rc = [%d]\n", __func__,
-                              ecryptfs_dentry->d_name.name, rc);
-                       goto out_free;
-               }
+       rc = ecryptfs_init_persistent_file(ecryptfs_dentry);
+       if (rc) {
+               printk(KERN_ERR "%s: Error attempting to initialize "
+                       "the persistent file for the dentry with name "
+                       "[%s]; rc = [%d]\n", __func__,
+                       ecryptfs_dentry->d_name.name, rc);
+               goto out_free;
        }
        if ((ecryptfs_inode_to_private(inode)->lower_file->f_flags & O_RDONLY)
            && !(file->f_flags & O_RDONLY)) {
index 64ff023307529820a02e5981d5fc805666751f10..bd33f87a19070bbb851dfad57d606a00c253dc81 100644 (file)
@@ -185,15 +185,13 @@ static int ecryptfs_initialize_file(struct dentry *ecryptfs_dentry)
                                "context; rc = [%d]\n", rc);
                goto out;
        }
-       if (!ecryptfs_inode_to_private(ecryptfs_dentry->d_inode)->lower_file) {
-               rc = ecryptfs_init_persistent_file(ecryptfs_dentry);
-               if (rc) {
-                       printk(KERN_ERR "%s: Error attempting to initialize "
-                              "the persistent file for the dentry with name "
-                              "[%s]; rc = [%d]\n", __func__,
-                              ecryptfs_dentry->d_name.name, rc);
-                       goto out;
-               }
+       rc = ecryptfs_init_persistent_file(ecryptfs_dentry);
+       if (rc) {
+               printk(KERN_ERR "%s: Error attempting to initialize "
+                       "the persistent file for the dentry with name "
+                       "[%s]; rc = [%d]\n", __func__,
+                       ecryptfs_dentry->d_name.name, rc);
+               goto out;
        }
        rc = ecryptfs_write_metadata(ecryptfs_dentry);
        if (rc) {
@@ -302,15 +300,13 @@ int ecryptfs_lookup_and_interpose_lower(struct dentry *ecryptfs_dentry,
                rc = -ENOMEM;
                goto out;
        }
-       if (!ecryptfs_inode_to_private(ecryptfs_dentry->d_inode)->lower_file) {
-               rc = ecryptfs_init_persistent_file(ecryptfs_dentry);
-               if (rc) {
-                       printk(KERN_ERR "%s: Error attempting to initialize "
-                              "the persistent file for the dentry with name "
-                              "[%s]; rc = [%d]\n", __func__,
-                              ecryptfs_dentry->d_name.name, rc);
-                       goto out_free_kmem;
-               }
+       rc = ecryptfs_init_persistent_file(ecryptfs_dentry);
+       if (rc) {
+               printk(KERN_ERR "%s: Error attempting to initialize "
+                       "the persistent file for the dentry with name "
+                       "[%s]; rc = [%d]\n", __func__,
+                       ecryptfs_dentry->d_name.name, rc);
+               goto out_free_kmem;
        }
        crypt_stat = &ecryptfs_inode_to_private(
                                        ecryptfs_dentry->d_inode)->crypt_stat;