summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGabriel Krisman Bertazi <krisman@collabora.com>2019-07-02 17:53:22 -0400
committerTheodore Ts'o <tytso@mit.edu>2019-07-02 17:56:12 -0400
commit96fcaf86c3cb9340015fb475d79ef0a6fcf858ed (patch)
tree800f08721544f6984ea1ef0a8db2ca28cab343b3
parent78e9605d4fdde6d58b2e6db5b6b52dde7f92333e (diff)
ext4: fix coverity warning on error path of filename setup
Fix the following coverity warning reported by Dan Carpenter: fs/ext4/namei.c:1311 ext4_fname_setup_ci_filename() warn: 'cf_name->len' unsigned <= 0 Fixes: 3ae72562ad91 ("ext4: optimize case-insensitive lookups") Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
-rw-r--r--fs/ext4/namei.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index c9568fee9e11..129029534075 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -1310,6 +1310,8 @@ int ext4_ci_compare(const struct inode *parent, const struct qstr *name,
1310void ext4_fname_setup_ci_filename(struct inode *dir, const struct qstr *iname, 1310void ext4_fname_setup_ci_filename(struct inode *dir, const struct qstr *iname,
1311 struct fscrypt_str *cf_name) 1311 struct fscrypt_str *cf_name)
1312{ 1312{
1313 int len;
1314
1313 if (!IS_CASEFOLDED(dir)) { 1315 if (!IS_CASEFOLDED(dir)) {
1314 cf_name->name = NULL; 1316 cf_name->name = NULL;
1315 return; 1317 return;
@@ -1319,13 +1321,16 @@ void ext4_fname_setup_ci_filename(struct inode *dir, const struct qstr *iname,
1319 if (!cf_name->name) 1321 if (!cf_name->name)
1320 return; 1322 return;
1321 1323
1322 cf_name->len = utf8_casefold(EXT4_SB(dir->i_sb)->s_encoding, 1324 len = utf8_casefold(EXT4_SB(dir->i_sb)->s_encoding,
1323 iname, cf_name->name, 1325 iname, cf_name->name,
1324 EXT4_NAME_LEN); 1326 EXT4_NAME_LEN);
1325 if (cf_name->len <= 0) { 1327 if (len <= 0) {
1326 kfree(cf_name->name); 1328 kfree(cf_name->name);
1327 cf_name->name = NULL; 1329 cf_name->name = NULL;
1330 return;
1328 } 1331 }
1332 cf_name->len = (unsigned) len;
1333
1329} 1334}
1330#endif 1335#endif
1331 1336