[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1bf42e57-e2d3-465a-9b5f-da219e23f825@stanley.mountain>
Date: Fri, 14 Mar 2025 17:13:41 +0300
From: Dan Carpenter <dan.carpenter@...aro.org>
To: Przemek Kitszel <przemyslaw.kitszel@...el.com>
Cc: Matthew Wilcox <willy@...radead.org>,
Michal Swiatkowski <michal.swiatkowski@...ux.intel.com>,
netdev@...r.kernel.org, jiri@...nulli.us, davem@...emloft.net,
edumazet@...gle.com, kuba@...nel.org, pabeni@...hat.com,
horms@...nel.org, pierre@...ckhpc.com, hkallweit1@...il.com,
linux@...linux.org.uk, maxime.chevallier@...tlin.com,
christophe.leroy@...roup.eu, arkadiusz.kubalewski@...el.com,
vadim.fedorenko@...ux.dev
Subject: Re: [PATCH net v2 0/3] fix xa_alloc_cyclic() return checks
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@...ckhpc.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
Powered by blists - more mailing lists