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: <YSYwxmCqDKL+qvY/@errol.ini.cmu.edu>
Date:   Wed, 25 Aug 2021 08:00:06 -0400
From:   "Gabriel L. Somlo" <gsomlo@...il.com>
To:     Joel Stanley <joel@....id.au>
Cc:     Florent Kermarrec <florent@...oy-digital.fr>,
        "David S . Miller" <davem@...emloft.net>,
        Jakub Kicinski <kuba@...nel.org>,
        Rob Herring <robh+dt@...nel.org>,
        Karol Gugala <kgugala@...micro.com>,
        Mateusz Holenko <mholenko@...micro.com>,
        devicetree <devicetree@...r.kernel.org>,
        Networking <netdev@...r.kernel.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        David Shah <dave@....me>, Stafford Horne <shorne@...il.com>
Subject: Re: [PATCH v2 2/2] net: Add driver for LiteX's LiteEth network
 interface

On Wed, Aug 25, 2021 at 06:35:17AM +0000, Joel Stanley wrote:
> > > +
> > > +     netdev = devm_alloc_etherdev(&pdev->dev, sizeof(*priv));
> > > +     if (!netdev)
> > > +             return -ENOMEM;
> > > +
> > > +     SET_NETDEV_DEV(netdev, &pdev->dev);
> > > +     platform_set_drvdata(pdev, netdev);
> > > +
> > > +     priv = netdev_priv(netdev);
> > > +     priv->netdev = netdev;
> > > +     priv->dev = &pdev->dev;
> > > +
> > > +     irq = platform_get_irq(pdev, 0);
> > > +     if (irq < 0) {
> > > +             dev_err(&pdev->dev, "Failed to get IRQ %d\n", irq);
> > > +             return irq;
> >
> > At this point, netdev has been dynamically allocated, and should
> > probably be free'd before liteeth_probe() is allowed to fail,
> > to avoid any potential leaks...
> 
> We use the managed variant of alloc_etherdev, which means the
> structure is freed by the driver core when the driver is removed. This
> saves having to open code the cleanup/free code.
> 
> Have a read of Documentation/driver-api/driver-model/devres.rst for
> more information.

That makes sense, thanks for the link!

Cheers,
--Gabriel

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ