lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Tue, 13 Feb 2024 12:45:00 +0200
From: Andy Shevchenko <andy.shevchenko@...il.com>
To: Nikita Shubin <nikita.shubin@...uefel.me>
Cc: Conor Dooley <conor.dooley@...rochip.com>, Ulf Hansson <ulf.hansson@...aro.org>, 
	Joel Stanley <joel@....id.au>, Linus Walleij <linus.walleij@...aro.org>, Wei Xu <xuwei5@...ilicon.com>, 
	Huisong Li <lihuisong@...wei.com>, Walker Chen <walker.chen@...rfivetech.com>, 
	Jonathan Neuschäfer <j.neuschaefer@....net>, 
	Arnd Bergmann <arnd@...db.de>, Alexander Sverdlin <alexander.sverdlin@...il.com>, 
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH v7 08/39] soc: Add SoC driver for Cirrus ep93xx

On Tue, Feb 13, 2024 at 11:33 AM Nikita Shubin
<nikita.shubin@...uefel.me> wrote:
> On Sun, 2024-02-04 at 18:52 +0200, andy.shevchenko@...il.com wrote:
> > Thu, Jan 18, 2024 at 11:20:51AM +0300, Nikita Shubin kirjoitti:

..

> > > +static struct auxiliary_device *ep93xx_adev_alloc(struct device
> > > *parent, const char *name,
> > > +                                                 struct
> > > ep93xx_map_info *info)
> > > +{
> > > +       struct ep93xx_regmap_adev *rdev;
> > > +       struct auxiliary_device *adev;
> > > +       int ret;
> > > +
> > > +       rdev = kzalloc(sizeof(*rdev), GFP_KERNEL);
> > > +       if (!rdev)
> > > +               return ERR_PTR(-ENOMEM);
> >
> > Use __free() ?
> > (You already included cleanup.h for other cases, why not using it
> > here?)
>
> Why should i want this ?

To eliminate the necessity of not forgetting to clean it up when it's needed.

> I don't want rdev being freed on out of scope
> - rdev is freed in ep93xx_adev_release().

It's irrelevant.

> But thank you, i've noticed a bug - i should free rdev and not adev
> both in ep93xx_adev_alloc() and ep93xx_adev_release().

Exactly to avoid such mistakes, so please switch to __free() along
with no_free_ptr().

> > > +       rdev->map = info->map;
> > > +       rdev->base = info->base;
> > > +       rdev->lock = &info->lock;
> > > +       rdev->write = ep93xx_regmap_write;
> > > +       rdev->update_bits = ep93xx_regmap_update_bits;
> > > +
> > > +       adev = &rdev->adev;
> > > +       adev->name = name;
> > > +       adev->dev.parent = parent;
> > > +       adev->dev.release = ep93xx_adev_release;
> > > +
> > > +       ret = auxiliary_device_init(adev);
> > > +       if (ret) {
> > > +               kfree(adev);
> > > +               return ERR_PTR(ret);
> > > +       }
> > > +
> > > +       return adev;
> > > +}

-- 
With Best Regards,
Andy Shevchenko

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ