From: Roger Luethi Date: Thu, 17 Mar 2011 06:37:21 +0000 (+0000) Subject: ethtool: __ethtool_set_sg: check for function pointer before using it X-Git-Tag: upstream/snapshot3+hdmi~10756^2~95 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5e5069b41d5b82bcadc1dbf73f48476b428c102f;p=platform%2Fadaptation%2Frenesas_rcar%2Frenesas_kernel.git ethtool: __ethtool_set_sg: check for function pointer before using it __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 Reviewed-by: Ben Hutchings Signed-off-by: David S. Miller --- 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;