diff options
author | Gabriel Krisman Bertazi <krisman@collabora.com> | 2019-07-03 00:53:22 +0300 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2019-07-03 00:56:12 +0300 |
commit | 96fcaf86c3cb9340015fb475d79ef0a6fcf858ed (patch) | |
tree | 800f08721544f6984ea1ef0a8db2ca28cab343b3 /fs | |
parent | 78e9605d4fdde6d58b2e6db5b6b52dde7f92333e (diff) | |
download | linux-96fcaf86c3cb9340015fb475d79ef0a6fcf858ed.tar.xz |
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>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/ext4/namei.c | 13 |
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, void ext4_fname_setup_ci_filename(struct inode *dir, const struct qstr *iname, struct fscrypt_str *cf_name) { + int len; + if (!IS_CASEFOLDED(dir)) { cf_name->name = NULL; return; @@ -1319,13 +1321,16 @@ void ext4_fname_setup_ci_filename(struct inode *dir, const struct qstr *iname, if (!cf_name->name) return; - cf_name->len = utf8_casefold(EXT4_SB(dir->i_sb)->s_encoding, - iname, cf_name->name, - EXT4_NAME_LEN); - if (cf_name->len <= 0) { + len = utf8_casefold(EXT4_SB(dir->i_sb)->s_encoding, + iname, cf_name->name, + EXT4_NAME_LEN); + if (len <= 0) { kfree(cf_name->name); cf_name->name = NULL; + return; } + cf_name->len = (unsigned) len; + } #endif |