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:   Wed, 14 Apr 2021 08:07:49 -0500
From:   Adam Ford <aford173@...il.com>
To:     Geert Uytterhoeven <geert@...ux-m68k.org>
Cc:     netdev <netdev@...r.kernel.org>,
        Adam Ford-BE <aford@...conembedded.com>,
        Sergei Shtylyov <sergei.shtylyov@...il.com>,
        "David S. Miller" <davem@...emloft.net>,
        Jakub Kicinski <kuba@...nel.org>,
        Rob Herring <robh+dt@...nel.org>,
        Linux-Renesas <linux-renesas-soc@...r.kernel.org>,
        "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" 
        <devicetree@...r.kernel.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH V4 2/2] net: ethernet: ravb: Enable optional refclk

On Tue, Apr 13, 2021 at 2:33 AM Geert Uytterhoeven <geert@...ux-m68k.org> wrote:
>
> Hi Adam,
>
> On Mon, Apr 12, 2021 at 3:27 PM Adam Ford <aford173@...il.com> wrote:
> > For devices that use a programmable clock for the AVB reference clock,
> > the driver may need to enable them.  Add code to find the optional clock
> > and enable it when available.
> >
> > Signed-off-by: Adam Ford <aford173@...il.com>
> > Reviewed-by: Andrew Lunn <andrew@...n.ch>
> >
> > ---
> > V4:  Eliminate the NULL check when disabling refclk, and add a line
> >      to disable the refclk if there is a failure after it's been
> >      initialized.
>
> Thanks for the update!
>
> > --- a/drivers/net/ethernet/renesas/ravb_main.c
> > +++ b/drivers/net/ethernet/renesas/ravb_main.c
> > @@ -2148,6 +2148,13 @@ static int ravb_probe(struct platform_device *pdev)
> >                 goto out_release;
> >         }
> >
> > +       priv->refclk = devm_clk_get_optional(&pdev->dev, "refclk");
> > +       if (IS_ERR(priv->refclk)) {
> > +               error = PTR_ERR(priv->refclk);
> > +               goto out_release;
>
> Note that this will call clk_disable_unprepare() in case of failure, which is
> fine, as that function is a no-op in case of a failed clock.

Geert,

A bot reported that if I jump to out_release may try to free a clock
if some instances where priv isn't defined.
Currently, the priv->clk isn't freed either.  I have heard some
back-and-forth discussions in other threads on whether or not devm
functions auto free or not.

I'm fine with sending a V5 to make the free for the refclock happen
only when the priv has successfully initialized.  Should I also add
one for freeing priv->clk and change all the other goto out_release
commands to point to this new section?

I am thinking it would like something like:

free_refclk:
    clk_disable_unprepare(priv->refclk);
free_clk;
    clk_disable_unprepare(priv->clk);
out_release:
    free_netdev(ndev);
    ....


adam
>
> > +       }
> > +       clk_prepare_enable(priv->refclk);
> > +
> >         ndev->max_mtu = 2048 - (ETH_HLEN + VLAN_HLEN + ETH_FCS_LEN);
> >         ndev->min_mtu = ETH_MIN_MTU;
> >
> > @@ -2244,6 +2251,7 @@ static int ravb_probe(struct platform_device *pdev)
> >         if (chip_id != RCAR_GEN2)
> >                 ravb_ptp_stop(ndev);
> >  out_release:
> > +       clk_disable_unprepare(priv->refclk);
> >         free_netdev(ndev);
> >
> >         pm_runtime_put(&pdev->dev);
>
> Reviewed-by: Geert Uytterhoeven <geert+renesas@...der.be>
>
> Gr{oetje,eeting}s,
>
>                         Geert
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@...ux-m68k.org
>
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
>                                 -- Linus Torvalds

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ