* [bug report] ext4: optimize case-insensitive lookups
@ 2019-06-24 12:29 Dan Carpenter
2019-06-28 20:19 ` [PATCH] ext4: Fix coverity warning on error path of filename setup Gabriel Krisman Bertazi
0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2019-06-24 12:29 UTC (permalink / raw)
To: krisman; +Cc: linux-ext4
Hello Gabriel Krisman Bertazi,
The patch 3ae72562ad91: "ext4: optimize case-insensitive lookups"
from Jun 19, 2019, leads to the following static checker warning:
fs/ext4/namei.c:1311 ext4_fname_setup_ci_filename()
warn: 'cf_name->len' unsigned <= 0
fs/ext4/namei.c
1296 void ext4_fname_setup_ci_filename(struct inode *dir, const struct qstr *iname,
1297 struct fscrypt_str *cf_name)
1298 {
1299 if (!IS_CASEFOLDED(dir)) {
1300 cf_name->name = NULL;
1301 return;
1302 }
1303
1304 cf_name->name = kmalloc(EXT4_NAME_LEN, GFP_NOFS);
1305 if (!cf_name->name)
1306 return;
1307
1308 cf_name->len = utf8_casefold(EXT4_SB(dir->i_sb)->s_encoding,
1309 iname, cf_name->name,
1310 EXT4_NAME_LEN);
utf8_casefold() returns negative error codes
1311 if (cf_name->len <= 0) {
but "cf_name->len" is a u32.
1312 kfree(cf_name->name);
1313 cf_name->name = NULL;
1314 }
1315 }
regards,
dan carpenter
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] ext4: Fix coverity warning on error path of filename setup
2019-06-24 12:29 [bug report] ext4: optimize case-insensitive lookups Dan Carpenter
@ 2019-06-28 20:19 ` Gabriel Krisman Bertazi
2019-07-02 21:57 ` Theodore Ts'o
0 siblings, 1 reply; 3+ messages in thread
From: Gabriel Krisman Bertazi @ 2019-06-28 20:19 UTC (permalink / raw)
To: Dan Carpenter; +Cc: linux-ext4, tytso, kernel
Dan Carpenter <dan.carpenter@oracle.com> writes:
> Hello Gabriel Krisman Bertazi,
>
> The patch 3ae72562ad91: "ext4: optimize case-insensitive lookups"
> from Jun 19, 2019, leads to the following static checker warning:
Hi,
The patch below should fix this issue.
-- >8 --
Subject: [PATCH] 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>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
---
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ext4: Fix coverity warning on error path of filename setup
2019-06-28 20:19 ` [PATCH] ext4: Fix coverity warning on error path of filename setup Gabriel Krisman Bertazi
@ 2019-07-02 21:57 ` Theodore Ts'o
0 siblings, 0 replies; 3+ messages in thread
From: Theodore Ts'o @ 2019-07-02 21:57 UTC (permalink / raw)
To: Gabriel Krisman Bertazi; +Cc: Dan Carpenter, linux-ext4, kernel
On Fri, Jun 28, 2019 at 04:19:32PM -0400, Gabriel Krisman Bertazi wrote:
> Dan Carpenter <dan.carpenter@oracle.com> writes:
>
> > Hello Gabriel Krisman Bertazi,
> >
> > The patch 3ae72562ad91: "ext4: optimize case-insensitive lookups"
> > from Jun 19, 2019, leads to the following static checker warning:
>
> Hi,
>
> The patch below should fix this issue.
>
> -- >8 --
> Subject: [PATCH] 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>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Applied, thanks.
- Ted
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-07-03 0:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-24 12:29 [bug report] ext4: optimize case-insensitive lookups Dan Carpenter
2019-06-28 20:19 ` [PATCH] ext4: Fix coverity warning on error path of filename setup Gabriel Krisman Bertazi
2019-07-02 21:57 ` Theodore Ts'o
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).