From: Dan Carpenter <dan.carpenter@oracle.com>
To: "Theodore Ts'o" <tytso@mit.edu>, Michael Halcrow <mhalcrow@google.com>
Cc: Andreas Dilger <adilger.kernel@dilger.ca>,
linux-ext4@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [patch] ext4 crypto: testing the wrong variable
Date: Wed, 8 Apr 2015 11:53:38 +0300 [thread overview]
Message-ID: <20150408085338.GA8837@mwanda> (raw)
The intention was to check "IS_ERR(*buf)" instead of "IS_ERR(buf)".
It's never an ERR_PTR() in the current code so this is a harmless
mistake.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
I have a static checker warning for when people check IS_ERR() and it's
not an error pointer. Adding these extra checks introduces deliberate
warnings and makes my work harder which means that bugs are missed.
Also there is no good reason to pass an ERR_PTR to
ext4_fname_crypto_free_buffer() but eventually someone will take
advantage of this feature to write ugly code. Ugly code is going to be
buggy.
At least do a "if (WARN_ON(IS_ERR(*buf))) return;". I could filter out
impossible conditions which are inside a WARN_ON() and it will mean
people don't actually pass error pointers here.
diff --git a/fs/ext4/crypto_fname.c b/fs/ext4/crypto_fname.c
index 5fda403..f076b52 100644
--- a/fs/ext4/crypto_fname.c
+++ b/fs/ext4/crypto_fname.c
@@ -558,7 +558,7 @@ int ext4_fname_crypto_alloc_buffer(struct ext4_fname_crypto_ctx *ctx,
*/
void ext4_fname_crypto_free_buffer(void **buf)
{
- if (*buf == NULL || IS_ERR(buf))
+ if (*buf == NULL || IS_ERR(*buf))
return;
kfree(*buf);
*buf = NULL;
next reply other threads:[~2015-04-08 8:53 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-08 8:53 Dan Carpenter [this message]
2015-04-08 9:51 ` [patch] ext4 crypto: testing the wrong variable Julia Lawall
2015-04-08 11:51 ` walter harms
2015-04-08 12:22 ` Dan Carpenter
2015-04-11 13:48 ` Theodore Ts'o
2015-04-15 9:26 ` Dan Carpenter
2015-04-08 18:15 ` Andreas Dilger
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=20150408085338.GA8837@mwanda \
--to=dan.carpenter@oracle.com \
--cc=adilger.kernel@dilger.ca \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-ext4@vger.kernel.org \
--cc=mhalcrow@google.com \
--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 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).