From f2e20eca5a5a6afa5e19f74defa8a8f2b44b06d8 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Thu, 18 Jul 2019 10:40:39 -0400 Subject: [PATCH] add patch fix-coverity-warning-on-error-path-of-filename-setup --- ...overity-warning-on-error-path-of-filename-setup | 56 ++++++++++++++++++++++ series | 1 + timestamps | 7 +-- 3 files changed, 61 insertions(+), 3 deletions(-) create mode 100644 fix-coverity-warning-on-error-path-of-filename-setup diff --git a/fix-coverity-warning-on-error-path-of-filename-setup b/fix-coverity-warning-on-error-path-of-filename-setup new file mode 100644 index 00000000..4204abeb --- /dev/null +++ b/fix-coverity-warning-on-error-path-of-filename-setup @@ -0,0 +1,56 @@ +ext4: fix coverity warning on error path of filename setup + +From: Gabriel Krisman Bertazi + +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 +Signed-off-by: Theodore Ts'o +Reported-by: Dan Carpenter +--- + fs/ext4/namei.c | 13 +++++++++---- + 1 file changed, 9 insertions(+), 4 deletions(-) + +diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c +index 4909ced4e672..898295286676 100644 +--- a/fs/ext4/namei.c ++++ b/fs/ext4/namei.c +@@ -1296,6 +1296,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; +@@ -1305,13 +1307,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 + +-- +2.20.1 + + + diff --git a/series b/series index ace16f6e..2c1ce4c0 100644 --- a/series +++ b/series @@ -19,6 +19,7 @@ rename-dirent-csum-functions-to-dirblock refactor-initialize_dirent_tail rename-htree_inlinedir_to_tree replace-ktype-default_attrs-with-default_groups +fix-coverity-warning-on-error-path-of-filename-setup #################################################### # unstable patches diff --git a/timestamps b/timestamps index 2a997ed9..4fff2933 100755 --- a/timestamps +++ b/timestamps @@ -31,6 +31,7 @@ touch -d @1561149107 refactor-initialize_dirent_tail touch -d @1561168620 rename-htree_inlinedir_to_tree touch -d @1561168680 stable-boundary touch -d @1562103535 replace-ktype-default_attrs-with-default_groups -touch -d @1562103570 series -touch -d @1562103575 status -touch -d @1562103651 timestamps +touch -d @1562104402 fix-coverity-warning-on-error-path-of-filename-setup +touch -d @1562104550 series +touch -d @1562104556 status +touch -d @1563460825 timestamps -- 2.11.4.GIT