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, 30 Dec 2015 16:12:57 +0100
From:	Andrew Lunn <andrew@...n.ch>
To:	Shaohui Xie <shaohui.xie@....com>
Cc:	David Miller <davem@...emloft.net>,
	Florian Fainelli <f.fainelli@...il.com>,
	netdev <netdev@...r.kernel.org>
Subject: Re: [PATCHv3 net-next 2/3] phy: marvell: Add ethtool statistics
 counters

On Wed, Dec 30, 2015 at 04:24:40AM +0000, Shaohui Xie wrote:
> > Subject: [PATCHv3 net-next 2/3] phy: marvell: Add ethtool statistics counters
> > +static int marvell_probe(struct phy_device *phydev) {
> > +	struct marvell_priv *priv;
> > +
> > +	priv = devm_kzalloc(&phydev->dev, sizeof(*priv), GFP_KERNEL);
> > +	if (!priv)
> > +		return -ENOMEM;
> > +
> > +	phydev->priv = priv;
> > +
> > +	return 0;
> > +}
> > +
> [S.H] Is a remove() function needed to free the memory?

Hi Shaohui

No, since i use devm_kzalloc(). The memory will automatically be freed
when phydev->dev is destroyed. Take a look at all the devm_ API calls
which have this property. They are useful for avoiding memory leaks,
especially on error paths.

     Andrew
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ