ethtool: __ethtool_set_sg: check for function pointer before using it
authorRoger Luethi <rl@hellgate.ch>
Thu, 17 Mar 2011 06:37:21 +0000 (06:37 +0000)
committerDavid S. Miller <davem@davemloft.net>
Fri, 18 Mar 2011 22:13:10 +0000 (15:13 -0700)
__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 <rl@hellgate.ch>
Reviewed-by: Ben Hutchings <bhutchings@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/ethtool.c

index c1a71bb738da4db6c8cd62b75d36b5d091316fd8..a1086fb0c0c7d0929db5a3f2f9cdae42d540c814 100644 (file)
@@ -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;