From: Wang Weidong <wangweidong1@huawei.com>
To: David Miller <davem@davemloft.net>
Cc: <netdev@vger.kernel.org>, Daniel Borkmann <dborkman@redhat.com>
Subject: [PATCH v2] ethtool: check the ethtool_ops is NULL in dev_ethtool
Date: Tue, 18 Feb 2014 09:42:56 +0800 [thread overview]
Message-ID: <5302BAA0.9060905@huawei.com> (raw)
In-Reply-To: <5301F32C.4040704@huawei.com>
some drivers maybe not implement the ethtool_ops with only
set NULL to ethtool_ops. So when call the ethtool devx will
lead to a 'NULL pointer dereference'.
So add a check in dev_ethtool
Signed-off-by: Wang Weidong <wangweidong1@huawei.com>
---
Change note:
v2: fix a trailing whitespace/tab pointed out by Daniel
---
net/core/ethtool.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index 30071de..c8cfd8f 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -1500,6 +1500,9 @@ int dev_ethtool(struct net *net, struct ifreq *ifr)
return -EPERM;
}
+ if (!dev->ethtool_ops)
+ return -EOPNOTSUPP;
+
if (dev->ethtool_ops->begin) {
rc = dev->ethtool_ops->begin(dev);
if (rc < 0)
--
1.7.12
next prev parent reply other threads:[~2014-02-18 1:43 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-17 11:31 [PATCH] ethtool: check the ethtool_ops is NULL in dev_ethtool Wang Weidong
2014-02-17 17:09 ` 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 ` Wang Weidong [this message]
2014-02-18 10:41 ` [PATCH v2] " 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=5302BAA0.9060905@huawei.com \
--to=wangweidong1@huawei.com \
--cc=davem@davemloft.net \
--cc=dborkman@redhat.com \
--cc=netdev@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.