netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Shaohui Xie <shaohui.xie@nxp.com>
Cc: David Miller <davem@davemloft.net>,
	Florian Fainelli <f.fainelli@gmail.com>,
	netdev <netdev@vger.kernel.org>
Subject: Re: [PATCHv3 net-next 2/3] phy: marvell: Add ethtool statistics counters
Date: Wed, 30 Dec 2015 16:12:57 +0100	[thread overview]
Message-ID: <20151230151257.GA16560@lunn.ch> (raw)
In-Reply-To: <VI1PR04MB1664FF303D53D9472E36452BE8FD0@VI1PR04MB1664.eurprd04.prod.outlook.com>

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

  reply	other threads:[~2015-12-30 15:13 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-29 19:51 [PATCHv3 net-next 0/3] Ethtool support for phy stats Andrew Lunn
2015-12-29 19:51 ` [PATCHv3 net-next 1/3] ethtool: Add phy statistics Andrew Lunn
2015-12-29 20:12   ` David Miller
2015-12-29 19:51 ` [PATCHv3 net-next 2/3] phy: marvell: Add ethtool statistics counters Andrew Lunn
2015-12-30  4:24   ` Shaohui Xie
2015-12-30 15:12     ` Andrew Lunn [this message]
2015-12-31  5:24       ` Shaohui Xie
2015-12-29 19:51 ` [PATCHv3 net-next 3/3] phy: micrel: " Andrew Lunn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151230151257.GA16560@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=shaohui.xie@nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).