Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Gabriel Krisman Bertazi and committed by
Theodore Ts'o
96fcaf86 78e9605d

+9 -4
+9 -4
fs/ext4/namei.c
··· 1310 1310 void ext4_fname_setup_ci_filename(struct inode *dir, const struct qstr *iname, 1311 1311 struct fscrypt_str *cf_name) 1312 1312 { 1313 + int len; 1314 + 1313 1315 if (!IS_CASEFOLDED(dir)) { 1314 1316 cf_name->name = NULL; 1315 1317 return; ··· 1321 1319 if (!cf_name->name) 1322 1320 return; 1323 1321 1324 - cf_name->len = utf8_casefold(EXT4_SB(dir->i_sb)->s_encoding, 1325 - iname, cf_name->name, 1326 - EXT4_NAME_LEN); 1327 - if (cf_name->len <= 0) { 1322 + len = utf8_casefold(EXT4_SB(dir->i_sb)->s_encoding, 1323 + iname, cf_name->name, 1324 + EXT4_NAME_LEN); 1325 + if (len <= 0) { 1328 1326 kfree(cf_name->name); 1329 1327 cf_name->name = NULL; 1328 + return; 1330 1329 } 1330 + cf_name->len = (unsigned) len; 1331 + 1331 1332 } 1332 1333 #endif 1333 1334