From: Dan Carpenter <dan.carpenter@linaro.org>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: "Baolin Wang" <baolin.wang@linux.alibaba.com>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
"Hans de Goede" <hdegoede@redhat.com>,
linux-kernel@vger.kernel.org,
platform-driver-x86@vger.kernel.org,
"Rafael J. Wysocki" <rafael@kernel.org>,
"Daniel Scally" <djrscally@gmail.com>
Subject: Re: [PATCH v2 1/4] driver core: Ignore 0 in dev_err_probe()
Date: Mon, 2 Sep 2024 16:12:11 +0300 [thread overview]
Message-ID: <29f8532e-324a-4e06-b257-3ef9a037f93f@stanley.mountain> (raw)
In-Reply-To: <ZtWjqkQUi74JFN1s@smile.fi.intel.com>
On Mon, Sep 02, 2024 at 02:38:18PM +0300, Andy Shevchenko wrote:
> > > I believe the number is only a few at most, which means that you may easily
> > > detect this still with this change being applied, i.e. "anything that
> > > terminates function flow with code 0, passed to dev_err_probe(), is
> > > suspicious".
> >
> > I think you mean the opposite of what you wrote? That if we're passing zero to
> > dev_err_probe() and it's the last line in a function it's *NOT* suspicious?
>
> Yes, sorry, I meant "...terminates function flow _in the middle_...".
>
I don't think that works. There are lots of success paths in the middle of
functions. Smatch already has code to determine whether we should return an
error code or not.
1) Was there a function that returned NULL
2) Was there a function that returned an erorr code/error pointer
3) Was there a bounds check where x >= y?
4) Did we print an error code?
Etc..
I'd end up re-using this code. This heuristic is more error prone, so there
would be false positives and missed bugs but I can't predict the future so I
don't know how bad it would be. Looking through the warnings, we still would be
able to detected a number of these because Smatch warnings when you pass NULL to
IS_ERR() or PTR_ERR().
Probably the worse thing from a Smatch perspective is that now I can't just
assume that dev_err_probe() is always an error path. So for example, we know
that *foo is always initialized on success so we can eliminate all the
"return dev_err_probe();" paths because those are failure path.
I'm never going to like this patch because I always want to make the error paths
more separate and more clear.
regards,
dan carpenter
next prev parent reply other threads:[~2024-09-02 13:12 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-22 13:05 [PATCH v2 0/4] platform/x86: int3472: A few cleanups Andy Shevchenko
2024-08-22 13:05 ` [PATCH v2 1/4] driver core: Ignore 0 in dev_err_probe() Andy Shevchenko
2024-08-24 3:08 ` Greg Kroah-Hartman
2024-08-28 16:58 ` Andy Shevchenko
2024-08-31 8:25 ` Dan Carpenter
2024-08-31 8:53 ` Dan Carpenter
2024-09-02 10:16 ` Andy Shevchenko
2024-09-02 11:10 ` Dan Carpenter
2024-09-02 11:38 ` Andy Shevchenko
2024-09-02 13:12 ` Dan Carpenter [this message]
2024-09-02 15:58 ` Johan Hovold
2024-09-02 16:10 ` Andy Shevchenko
2024-08-22 13:05 ` [PATCH v2 2/4] platform/x86: int3472: Simplify dev_err_probe() usage Andy Shevchenko
2024-08-31 8:31 ` Dan Carpenter
2024-09-02 10:17 ` Andy Shevchenko
2024-09-02 11:23 ` Dan Carpenter
2024-09-02 11:32 ` Hans de Goede
2024-08-22 13:05 ` [PATCH v2 3/4] platform/x86: int3472: Use GPIO_LOOKUP() macro Andy Shevchenko
2024-08-22 13:05 ` [PATCH v2 4/4] platform/x86: int3472: Use str_high_low() Andy Shevchenko
2024-09-02 10:19 ` [PATCH v2 0/4] platform/x86: int3472: A few cleanups Andy Shevchenko
2024-09-04 13:05 ` Hans de Goede
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=29f8532e-324a-4e06-b257-3ef9a037f93f@stanley.mountain \
--to=dan.carpenter@linaro.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=baolin.wang@linux.alibaba.com \
--cc=djrscally@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=hdegoede@redhat.com \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=platform-driver-x86@vger.kernel.org \
--cc=rafael@kernel.org \
/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®