Commit 96fcaf86 authored by Gabriel Krisman Bertazi's avatar Gabriel Krisman Bertazi Committed by Theodore Ts'o

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: 3ae72562 ("ext4: optimize case-insensitive lookups")
Signed-off-by: default avatarGabriel Krisman Bertazi <krisman@collabora.com>
Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
parent 78e9605d
...@@ -1310,6 +1310,8 @@ int ext4_ci_compare(const struct inode *parent, const struct qstr *name, ...@@ -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, void ext4_fname_setup_ci_filename(struct inode *dir, const struct qstr *iname,
struct fscrypt_str *cf_name) struct fscrypt_str *cf_name)
{ {
int len;
if (!IS_CASEFOLDED(dir)) { if (!IS_CASEFOLDED(dir)) {
cf_name->name = NULL; cf_name->name = NULL;
return; return;
...@@ -1319,13 +1321,16 @@ void ext4_fname_setup_ci_filename(struct inode *dir, const struct qstr *iname, ...@@ -1319,13 +1321,16 @@ void ext4_fname_setup_ci_filename(struct inode *dir, const struct qstr *iname,
if (!cf_name->name) if (!cf_name->name)
return; return;
cf_name->len = utf8_casefold(EXT4_SB(dir->i_sb)->s_encoding, len = utf8_casefold(EXT4_SB(dir->i_sb)->s_encoding,
iname, cf_name->name, iname, cf_name->name,
EXT4_NAME_LEN); EXT4_NAME_LEN);
if (cf_name->len <= 0) { if (len <= 0) {
kfree(cf_name->name); kfree(cf_name->name);
cf_name->name = NULL; cf_name->name = NULL;
return;
} }
cf_name->len = (unsigned) len;
} }
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment