public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@linaro.org>
To: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Cc: Matthew Wilcox <willy@infradead.org>,
	Michal Swiatkowski <michal.swiatkowski@linux.intel.com>,
	netdev@vger.kernel.org, jiri@resnulli.us, davem@davemloft.net,
	edumazet@google.com, kuba@kernel.org, pabeni@redhat.com,
	horms@kernel.org, pierre@stackhpc.com, hkallweit1@gmail.com,
	linux@armlinux.org.uk, maxime.chevallier@bootlin.com,
	christophe.leroy@csgroup.eu, arkadiusz.kubalewski@intel.com,
	vadim.fedorenko@linux.dev
Subject: Re: [PATCH net v2 0/3] fix xa_alloc_cyclic() return checks
Date: Fri, 14 Mar 2025 17:13:41 +0300	[thread overview]
Message-ID: <1bf42e57-e2d3-465a-9b5f-da219e23f825@stanley.mountain> (raw)
In-Reply-To: <122bc3a2-2150-4661-8d08-2082e0e7a9d7@intel.com>

On Fri, Mar 14, 2025 at 01:52:58PM +0100, Przemek Kitszel wrote:
> On 3/14/25 11:23, Dan Carpenter wrote:
> > On Wed, Mar 12, 2025 at 10:52:48AM +0100, Michal Swiatkowski wrote:
> > > Pierre Riteau <pierre@stackhpc.com> found suspicious handling an error
> > > from xa_alloc_cyclic() in scheduler code [1]. The same is done in few
> > > other places.
> > > 
> > > v1 --> v2: [2]
> > >   * add fixes tags
> > >   * fix also the same usage in dpll and phy
> > > 
> > > [1] https://lore.kernel.org/netdev/20250213223610.320278-1-pierre@stackhpc.com/
> > > [2] https://lore.kernel.org/netdev/20250214132453.4108-1-michal.swiatkowski@linux.intel.com/
> > > 
> > > Michal Swiatkowski (3):
> > >    devlink: fix xa_alloc_cyclic() error handling
> > >    dpll: fix xa_alloc_cyclic() error handling
> > >    phy: fix xa_alloc_cyclic() error handling
> > 
> > Maybe there should be a wrapper around xa_alloc_cyclic() for people who
> > don't care about the 1 return?
> 
> What about changing init flags instead, and add a new one for this
> purpose?, say:
> XA_FLAGS_ALLOC_RET0

Right now I have a static checker rule for passing 1 to ERR_PTR().
It's not specific to this function but it catches the bugs here.  If we
added a XA_FLAGS_ALLOC_RET0 then I'd have to silence the checker rule for
xa_alloc_cyclic().

I was also thinking about creating another more specific rule for just this
function to warn about when callers which treat 1 and negative error
codes the same, but that wouldn't be possible.

On the other hand, people who pass XA_FLAGS_ALLOC_RET0 probably will
understand what it means and not introduce bugs so static analysis becomes
less important in that case.

regards,
dan carpenter


  reply	other threads:[~2025-03-14 14:13 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-12  9:52 [PATCH net v2 0/3] fix xa_alloc_cyclic() return checks Michal Swiatkowski
2025-03-12  9:52 ` [PATCH net v2 1/3] devlink: fix xa_alloc_cyclic() error handling Michal Swiatkowski
2025-03-12 13:15   ` Andrew Lunn
2025-03-14 13:33   ` Jiri Pirko
2025-03-12  9:52 ` [PATCH net v2 2/3] dpll: " Michal Swiatkowski
2025-03-12 10:33   ` Vadim Fedorenko
2025-03-12 10:55   ` Kubalewski, Arkadiusz
2025-03-14 13:33   ` Jiri Pirko
2025-03-12  9:52 ` [PATCH net v2 3/3] phy: " Michal Swiatkowski
2025-03-12 11:35   ` Maxime Chevallier
2025-03-14 10:23 ` [PATCH net v2 0/3] fix xa_alloc_cyclic() return checks Dan Carpenter
2025-03-14 12:52   ` Przemek Kitszel
2025-03-14 14:13     ` Dan Carpenter [this message]
2025-03-14 14:23     ` Matthew Wilcox
2025-03-17  8:55       ` Przemek Kitszel
2025-03-17 12:24         ` Matthew Wilcox
2025-03-19  8:45           ` Przemek Kitszel
2025-03-19 10:00 ` patchwork-bot+netdevbpf

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=1bf42e57-e2d3-465a-9b5f-da219e23f825@stanley.mountain \
    --to=dan.carpenter@linaro.org \
    --cc=arkadiusz.kubalewski@intel.com \
    --cc=christophe.leroy@csgroup.eu \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hkallweit1@gmail.com \
    --cc=horms@kernel.org \
    --cc=jiri@resnulli.us \
    --cc=kuba@kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=maxime.chevallier@bootlin.com \
    --cc=michal.swiatkowski@linux.intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pierre@stackhpc.com \
    --cc=przemyslaw.kitszel@intel.com \
    --cc=vadim.fedorenko@linux.dev \
    --cc=willy@infradead.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