Thread (4 messages) flat view 4 messages, 4 authors, 2011-03-18

Re: [PATCH] ethtool: __ethtool_set_sg: check for function pointer before using it

From: Ben Hutchings <hidden>
Date: 2011-03-17 16:52:16

On Thu, 2011-03-17 at 17:37 +0100, Roger Luethi wrote:
__ethtool_set_sg does not check if dev->ethtool_ops->set_sg is defined
which can result in a NULL pointer dereference when ethtool is used to
change SG settings for drivers without SG support.

Signed-off-by: Roger Luethi <redacted>
Reviewed-by: Ben Hutchings <redacted>

Michał, was this just an oversight or is there some reason why we
shouldn't check set_sg immediately?

Ben.
quoted hunk ↗ jump to hunk
---

Bug verified. Patch only compile-tested.

 net/core/ethtool.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index c1a71bb..a1086fb 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -1457,6 +1457,9 @@ static int __ethtool_set_sg(struct net_device *dev, u32 data)
 {
 	int err;
 
+	if (!dev->ethtool_ops->set_sg)
+		return -EOPNOTSUPP;
+
 	if (data && !(dev->features & NETIF_F_ALL_CSUM))
 		return -EINVAL;
 
-- 
Ben Hutchings, Senior Software Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help