RE: [PATCHv3 net-next 2/3] phy: marvell: Add ethtool statistics counters
From: Shaohui Xie <hidden>
Date: 2015-12-31 05:39:53
From: Shaohui Xie <hidden>
Date: 2015-12-31 05:39:53
-----Original Message----- From: Andrew Lunn [mailto:andrew@lunn.ch] Sent: Wednesday, December 30, 2015 11:13 PM To: Shaohui Xie Cc: David Miller; Florian Fainelli; netdev 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:quoted
quoted
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.
Got it. Thank you! Shaohui