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]
Message-ID: <20240807152927.22e40284@bootlin.com>
Date: Wed, 7 Aug 2024 15:29:27 +0200
From: Herve Codina <herve.codina@...tlin.com>
To: Andy Shevchenko <andy.shevchenko@...il.com>
Cc: Geert Uytterhoeven <geert@...ux-m68k.org>, Simon Horman
 <horms@...nel.org>, Lee Jones <lee@...nel.org>, Arnd Bergmann
 <arnd@...db.de>, Derek Kiernan <derek.kiernan@....com>, Dragan Cvetic
 <dragan.cvetic@....com>, Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
 Bjorn Helgaas <bhelgaas@...gle.com>, Philipp Zabel
 <p.zabel@...gutronix.de>, Lars Povlsen <lars.povlsen@...rochip.com>, Steen
 Hegelund <Steen.Hegelund@...rochip.com>, Daniel Machon
 <daniel.machon@...rochip.com>, UNGLinuxDriver@...rochip.com, Rob Herring
 <robh@...nel.org>, Saravana Kannan <saravanak@...gle.com>, "David S.
 Miller" <davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>, Jakub
 Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>, Horatiu Vultur
 <horatiu.vultur@...rochip.com>, Andrew Lunn <andrew@...n.ch>,
 linux-kernel@...r.kernel.org, netdev@...r.kernel.org,
 linux-pci@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
 devicetree@...r.kernel.org, Allan Nielsen <allan.nielsen@...rochip.com>,
 Luca Ceresoli <luca.ceresoli@...tlin.com>, Thomas Petazzoni
 <thomas.petazzoni@...tlin.com>, Clément Léger
 <clement.leger@...tlin.com>
Subject: Re: [PATCH v4 3/8] mfd: syscon: Add reference counting and device
 managed support

Hi Andy,

On Mon, 5 Aug 2024 22:20:56 +0200
Andy Shevchenko <andy.shevchenko@...il.com> wrote:

> On Mon, Aug 5, 2024 at 12:19 PM Herve Codina <herve.codina@...tlin.com> wrote:
> >
> > From: Clément Léger <clement.leger@...tlin.com>
> >
> > Syscon releasing is not supported.
> > Without release function, unbinding a driver that uses syscon whether
> > explicitly or due to a module removal left the used syscon in a in-use
> > state.
> >
> > For instance a syscon_node_to_regmap() call from a consumer retrieve a  
> 
> retrieves?

Indeed, will be fixed.

> 
> > syscon regmap instance. Internally, syscon_node_to_regmap() can create
> > syscon instance and add it to the existing syscon list. No API is
> > available to release this syscon instance, remove it from the list and
> > free it when it is not used anymore.
> >
> > Introduce reference counting in syscon in order to keep track of syscon
> > usage using syscon_{get,put}() and add a device managed version of
> > syscon_regmap_lookup_by_phandle(), to automatically release the syscon
> > instance on the consumer removal.  
> 
> ...
> 
> > -       if (!syscon)
> > +       if (!syscon) {
> >                 syscon = of_syscon_register(np, check_res);
> > +               if (IS_ERR(syscon))
> > +                       return ERR_CAST(syscon);
> > +       } else {
> > +               syscon_get(syscon);
> > +       }  
> 
>   if (syscon)
>     return syscon_get();
> 
> ?
> 
> > +       return syscon;  

Yes and further more, I will remove also the unneeded IS_ERR() and ERR_CAST().
This will lead to just:

	if (syscon)
		return syscon_get(syscon);

	return of_syscon_register(np, check_res);

> 
> ...
> 
> > +static struct regmap *__devm_syscon_get(struct device *dev,
> > +                                       struct syscon *syscon)
> > +{
> > +       struct syscon **ptr;
> > +
> > +       if (IS_ERR(syscon))
> > +               return ERR_CAST(syscon);
> > +
> > +       ptr = devres_alloc(devm_syscon_release, sizeof(struct syscon *), GFP_KERNEL);
> > +       if (!ptr) {
> > +               syscon_put(syscon);
> > +               return ERR_PTR(-ENOMEM);
> > +       }
> > +
> > +       *ptr = syscon;
> > +       devres_add(dev, ptr);
> > +
> > +       return syscon->regmap;  
> 
> Can't the devm_add_action_or_reset() be used in this case? If so,
> perhaps a comment to explain why?

There is no reason to avoid the use of devm_add_action_or_reset() here.
So, I will use it in the next iteration.

Thanks for your review.

Best regards,
Hervé

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ