netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Kicinski <jakub.kicinski@netronome.com>
To: davem@davemloft.net, jiri@resnulli.us
Cc: mkubecek@suse.cz, andrew@lunn.ch, f.fainelli@gmail.com,
	netdev@vger.kernel.org, oss-drivers@netronome.com,
	Jakub Kicinski <jakub.kicinski@netronome.com>
Subject: [PATCH net-next v2 2/5] ethtool: hold a reference to the netdevice around devlink compat
Date: Fri, 22 Feb 2019 11:54:07 -0800	[thread overview]
Message-ID: <20190222195410.9494-3-jakub.kicinski@netronome.com> (raw)
In-Reply-To: <20190222195410.9494-1-jakub.kicinski@netronome.com>

When calling into devlink compat code make sure we have a reference
on the netdevice on which the operation was invoked.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
---
 net/core/ethtool.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index 1320e8dce559..6832476dfcaf 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -805,11 +805,14 @@ static noinline_for_stack int ethtool_get_drvinfo(struct net_device *dev,
 	if (ops->get_eeprom_len)
 		info.eedump_len = ops->get_eeprom_len(dev);
 
-	rtnl_unlock();
-	if (!info.fw_version[0])
+	if (!info.fw_version[0]) {
+		dev_hold(dev);
+		rtnl_unlock();
 		devlink_compat_running_version(dev, info.fw_version,
 					       sizeof(info.fw_version));
-	rtnl_lock();
+		rtnl_lock();
+		dev_put(dev);
+	}
 
 	if (copy_to_user(useraddr, &info, sizeof(info)))
 		return -EFAULT;
@@ -2043,9 +2046,11 @@ static noinline_for_stack int ethtool_flash_device(struct net_device *dev,
 	if (!dev->ethtool_ops->flash_device) {
 		int ret;
 
+		dev_hold(dev);
 		rtnl_unlock();
 		ret = devlink_compat_flash_update(dev, efl.data);
 		rtnl_lock();
+		dev_put(dev);
 
 		return ret;
 	}
-- 
2.19.2


  parent reply	other threads:[~2019-02-22 19:54 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-22 19:54 [PATCH net-next v2 0/5] devlink: make ethtool compat reliable Jakub Kicinski
2019-02-22 19:54 ` [PATCH net-next v2 1/5] net: devlink: turn devlink into a built-in Jakub Kicinski
2019-02-22 20:07   ` Florian Fainelli
2019-02-22 19:54 ` Jakub Kicinski [this message]
2019-02-22 20:09   ` [PATCH net-next v2 2/5] ethtool: hold a reference to the netdevice around devlink compat Florian Fainelli
2019-02-22 21:20     ` Jakub Kicinski
2019-02-22 19:54 ` [PATCH net-next v2 3/5] devlink: create a special NDO for getting the devlink instance Jakub Kicinski
2019-02-22 20:04   ` Florian Fainelli
2019-02-22 20:09     ` Jakub Kicinski
2019-02-22 19:54 ` [PATCH net-next v2 4/5] nfp: add .ndo_get_devlink Jakub Kicinski
2019-02-22 19:54 ` [PATCH net-next v2 5/5] nfp: remove ethtool flashing fallback Jakub Kicinski

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=20190222195410.9494-3-jakub.kicinski@netronome.com \
    --to=jakub.kicinski@netronome.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=jiri@resnulli.us \
    --cc=mkubecek@suse.cz \
    --cc=netdev@vger.kernel.org \
    --cc=oss-drivers@netronome.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).