Merge "ext4 crypto: use dget_parent() in ext4_d_revalidate()"

This commit is contained in:
Linux Build Service Account 2016-09-12 21:29:48 -07:00 committed by Gerrit - the friendly Code Review server
commit d8cee129cd

View file

@ -482,13 +482,16 @@ uint32_t ext4_validate_encryption_key_size(uint32_t mode, uint32_t size)
*/ */
static int ext4_d_revalidate(struct dentry *dentry, unsigned int flags) static int ext4_d_revalidate(struct dentry *dentry, unsigned int flags)
{ {
struct inode *dir = d_inode(dentry->d_parent); struct dentry *dir;
struct ext4_crypt_info *ci = EXT4_I(dir)->i_crypt_info; struct ext4_crypt_info *ci;
int dir_has_key, cached_with_key; int dir_has_key, cached_with_key;
if (!ext4_encrypted_inode(dir)) dir = dget_parent(dentry);
if (!ext4_encrypted_inode(d_inode(dir))) {
dput(dir);
return 0; return 0;
}
ci = EXT4_I(d_inode(dir))->i_crypt_info;
if (ci && ci->ci_keyring_key && if (ci && ci->ci_keyring_key &&
(ci->ci_keyring_key->flags & ((1 << KEY_FLAG_INVALIDATED) | (ci->ci_keyring_key->flags & ((1 << KEY_FLAG_INVALIDATED) |
(1 << KEY_FLAG_REVOKED) | (1 << KEY_FLAG_REVOKED) |
@ -498,6 +501,7 @@ static int ext4_d_revalidate(struct dentry *dentry, unsigned int flags)
/* this should eventually be an flag in d_flags */ /* this should eventually be an flag in d_flags */
cached_with_key = dentry->d_fsdata != NULL; cached_with_key = dentry->d_fsdata != NULL;
dir_has_key = (ci != NULL); dir_has_key = (ci != NULL);
dput(dir);
/* /*
* If the dentry was cached without the key, and it is a * If the dentry was cached without the key, and it is a