public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Wang Weidong <wangweidong1@huawei•com>
To: David Miller <davem@davemloft•net>
Cc: <netdev@vger•kernel.org>
Subject: [PATCH] ethtool: check the ethtool_ops is NULL in dev_ethtool
Date: Mon, 17 Feb 2014 19:31:56 +0800	[thread overview]
Message-ID: <5301F32C.4040704@huawei.com> (raw)

some drivers maybe not implement the ethtool_ops with only
set NULL. So when call the ethtool cmds will lead to a 
'NULL pointer dereference'.

So add a checking in dev_ethtool.

Signed-off-by: Wang Weidong <wangweidong1@huawei•com>
---
 net/core/ethtool.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index 30071de..f418dcb 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -1499,6 +1499,9 @@ int dev_ethtool(struct net *net, struct ifreq *ifr)
 		if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
 			return -EPERM;
 	}
+	
+	if (!dev->ethtool_ops)
+		return -EOPNOTSUPP;
 
 	if (dev->ethtool_ops->begin) {
 		rc = dev->ethtool_ops->begin(dev);
-- 
1.7.12

             reply	other threads:[~2014-02-17 11:32 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-17 11:31 Wang Weidong [this message]
2014-02-17 17:09 ` [PATCH] ethtool: check the ethtool_ops is NULL in dev_ethtool Daniel Borkmann
2014-02-18  1:20   ` Wang Weidong
2014-02-18  9:22     ` Daniel Borkmann
2014-02-18 10:40       ` Wang Weidong
2014-02-18  1:42 ` [PATCH v2] " Wang Weidong
2014-02-18 10:41   ` Wang Weidong

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=5301F32C.4040704@huawei.com \
    --to=wangweidong1@huawei$(echo .)com \
    --cc=davem@davemloft$(echo .)net \
    --cc=netdev@vger$(echo .)kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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