Re: [PATCH 3/4] nvmem: imx-ocotp: Support accessing controller for i.MX8M Nano

From: Alexander Stein
Date: Fri Jan 31 2025 - 08:51:10 EST


Hi,

Am Freitag, 31. Januar 2025, 08:20:40 CET schrieb Krzysztof Kozlowski:
> On 30/01/2025 14:01, Alexander Stein wrote:
> > +
> > +static int imx_ocotp_grant_access(struct ocotp_priv *priv, struct device_node *parent)
> > +{
> > + struct device *dev = priv->dev;
> > +
> > + for_each_available_child_of_node_scoped(parent, child) {
> > + struct of_phandle_args args;
> > + u32 id, idx = 0;
> > +
> > + while (!of_parse_phandle_with_args(child, "access-controllers",
> > + "#access-controller-cells",
> > + idx++, &args)) {
> > + of_node_put(args.np);
> > + if (args.np != dev->of_node)
>
> You are using args.np after dropping the reference.

Indeed, but is it really a problem? The args.np pointer is still the same.
So the comparison is unaffected.

Both branches need to drop the reference, no?
But the following looks awefull as well.
> if (args.np != dev->of_node) {
> of_node_put(args.np);
> continue;
> }
> of_node_put(args.np);

Best regards,
Alexander

>
> > + continue;
> > +
> > + /* Only support one cell */
> > + if (args.args_count != 1) {
> > + dev_err(dev, "wrong args count\n");
> > + continue;
> > + }
> > +
>
>
> Best regards,
> Krzysztof
>


--
TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany
Amtsgericht München, HRB 105018
Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider
http://www.tq-group.com/