2015-05-25 10:09:10

by Chao Yu

[permalink] [raw]
Subject: [PATCH 2/3] f2fs crypto: check dir entry just for directory

This patch fixes to add a judgement condition to verify type of the
target inode before empty directory verification.

So wrong verification could be avoided for non-directory inode.

Signed-off-by: Chao Yu <[email protected]>
---
fs/f2fs/crypto_policy.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/f2fs/crypto_policy.c b/fs/f2fs/crypto_policy.c
index bef254b..56b2ac0 100644
--- a/fs/f2fs/crypto_policy.c
+++ b/fs/f2fs/crypto_policy.c
@@ -93,7 +93,7 @@ int f2fs_process_policy(const struct f2fs_encryption_policy *policy,
return -EINVAL;

if (!f2fs_inode_has_encryption_context(inode)) {
- if (!f2fs_empty_dir(inode))
+ if (S_ISDIR(inode->i_mode) && !f2fs_empty_dir(inode))
return -ENOTEMPTY;
return f2fs_create_encryption_context_from_policy(inode,
policy);
--
2.3.0