[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <302d88ca-7d28-4450-8e60-d0bb40f4174d@kili.mountain>
Date: Mon, 3 Apr 2023 10:34:27 +0300
From: Dan Carpenter <error27@...il.com>
To: Geert Uytterhoeven <geert@...ux-m68k.org>
Cc: Li Yang <lidaxian@...t.edu.cn>,
Magnus Damm <magnus.damm@...il.com>,
Lad Prabhakar <prabhakar.mahadev-lad.rj@...renesas.com>,
Biju Das <biju.das.jz@...renesas.com>,
linux-renesas-soc@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] soc: renesas: renesas-soc: release 'chipid' from
ioremap()
On Mon, Apr 03, 2023 at 09:12:55AM +0200, Geert Uytterhoeven wrote:
> Hi Dan,
>
> On Mon, Apr 3, 2023 at 6:29 AM Dan Carpenter <error27@...il.com> wrote:
> > On Fri, Mar 31, 2023 at 02:13:10PM +0200, Geert Uytterhoeven wrote:
> > > On Fri, Mar 31, 2023 at 12:14 PM Li Yang <lidaxian@...t.edu.cn> wrote:
> > > > Smatch reports:
> > > >
> > > > drivers/soc/renesas/renesas-soc.c:536 renesas_soc_init() warn:
> > > > 'chipid' from ioremap() not released on lines: 475.
> > > >
> > > > If soc_dev_atrr allocation is failed, function renesas_soc_init()
> > > > will return without releasing 'chipid' from ioremap().
> > > >
> > > > Fix this by adding function iounmap().
> > > >
> > > > Fixes: cb5508e47e60 ("soc: renesas: Add support for reading product revision for RZ/G2L family")
> > > > Signed-off-by: Li Yang <lidaxian@...t.edu.cn>
> > > > Reviewed-by: Dan Carpenter <error27@...il.com>
> > >
> > > Thanks for your patch!
> > >
> > > > --- a/drivers/soc/renesas/renesas-soc.c
> > > > +++ b/drivers/soc/renesas/renesas-soc.c
> > > > @@ -471,8 +471,11 @@ static int __init renesas_soc_init(void)
> > > > }
> > > >
> > > > soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL);
> > > > - if (!soc_dev_attr)
> > > > + if (!soc_dev_attr) {
> > > > + if (chipid)
> > > > + iounmap(chipid);
> > >
> > > We don't really care, as the system is dead at this point anyway.
> >
> > Why even have the check for NULL then? The kzalloc() is small enough
>
> Because else someone will submit a patch to add that check? ;-)
>
> > to the point where it litterally cannot fail.
>
> I still don't understand how it can be guaranteed that small allocations
> never fail... "while (1) kmalloc(16, GFP_KERNEL);"
>
I read an lwn article on it and I think I once looked it up to try
figure out how small the definition of "small" was and it was
surprisingly large... But I have no idea. I think maybe small atomic
allocations can fail and GFP_KERNEL allocations sleep forever? (These
guesses are worthless).
> Perhaps we need a different mechanism to annotate error handling code
> that cannot ever happen in a real product, so it can be thrown away by
> the compiler, while still pleasing the static checkers? All these
> checks and error handling code do affect kernel size. There are
> Linux products running on SoCs with 8 MiB of internal SRAM.
People sometimes call BUG_ON(!soc_dev_attr). It's sort of rare these
days. It would be easy to make a function which silences Smatch...
__system_is_dead();
regards,
dan carpenter
Powered by blists - more mailing lists