From: Dan Carpenter <dan.carpenter@linaro.org>
To: Amir Goldstein <amir73il@gmail.com>
Cc: Charles Han <hanchunchao@inspur.com>,
miklos@szeredi.hu, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ovl: Fix PTR_ERR zero argument warning
Date: Fri, 23 May 2025 10:34:10 +0300 [thread overview]
Message-ID: <aDAk8pUwf6ZjDYQN@stanley.mountain> (raw)
In-Reply-To: <CAOQ4uxjU+RC_8Ec62irOy-Kd7H6UGuqpasq1qb5fXmZgkj_tUg@mail.gmail.com>
On Mon, May 19, 2025 at 08:43:16AM +0200, Amir Goldstein wrote:
> > @@ -577,7 +579,9 @@ struct dentry *ovl_index_upper(struct ovl_fs *ofs, struct dentry *index,
> > return dget(index);
> >
> > fh = ovl_get_fh(ofs, index, OVL_XATTR_UPPER);
> > - if (IS_ERR_OR_NULL(fh))
> > + if (!fh)
> > + return ERR_PTR(-ENODATA);
> > + else if (IS_ERR(fh))
> > return ERR_CAST(fh);
>
> I don't see what's wrong with casting a NULL pointer.
> This looks like a dubious smatch warning.
>
> We could add ERR_OR_NULL_CAST() but it seems pointless.
The ERR_OR_NULL_CAST() define is kind of a horrible name but I can't
think of a better one... To me, it's easy enough to just ignore
false positives.
This warning obviously does have false positives, but over half the
time it points to real bugs like:
p = kmalloc(sizeof(*p));
if (!p)
return PTR_ERR(p);
Or copy and paste bugs etc. There are lots of ways to get it wrong.
These warnings are always worth checking.
People should generally assume that static checker warnings in old code
are false positives. We're good at fixing all the real bugs. I didn't
report this warning because I knew the code was correct but I did look at
it on Feb 22, 2019. It can sometimes be helpful to look up the warning
on lore. We had a discussion about this one in 2020-04-21:
https://lore.kernel.org/all/?q=ovl_index_upper%20carpenter
regards,
dan carpenter
prev parent reply other threads:[~2025-05-23 7:34 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-19 4:11 Charles Han
2025-05-19 6:43 ` Amir Goldstein
2025-05-23 7:34 ` Dan Carpenter [this message]
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=aDAk8pUwf6ZjDYQN@stanley.mountain \
--to=dan.carpenter@linaro.org \
--cc=amir73il@gmail.com \
--cc=hanchunchao@inspur.com \
--cc=linux-kernel@vger.kernel.org \
--cc=miklos@szeredi.hu \
/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
all inboxes | Powered by JetHome®