From: Gabriel Krisman Bertazi <krisman@collabora.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: linux-ext4@vger.kernel.org, tytso@mit.edu, kernel@collabora.com
Subject: [PATCH] ext4: Fix coverity warning on error path of filename setup
Date: Fri, 28 Jun 2019 16:19:32 -0400 [thread overview]
Message-ID: <85r27dlay3.fsf@collabora.com> (raw)
In-Reply-To: <20190624122906.GA30836@mwanda> (Dan Carpenter's message of "Mon, 24 Jun 2019 15:29:06 +0300")
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
next prev parent reply other threads:[~2019-06-28 20:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-24 12:29 [bug report] ext4: optimize case-insensitive lookups Dan Carpenter
2019-06-28 20:19 ` Gabriel Krisman Bertazi [this message]
2019-07-02 21:57 ` [PATCH] ext4: Fix coverity warning on error path of filename setup Theodore Ts'o
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=85r27dlay3.fsf@collabora.com \
--to=krisman@collabora.com \
--cc=dan.carpenter@oracle.com \
--cc=kernel@collabora.com \
--cc=linux-ext4@vger.kernel.org \
--cc=tytso@mit.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.