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 <rl@hellgate.ch>
Reviewed-by: Ben Hutchings <bhutchings@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by Roger Luethi and committed by David S. Miller 5e5069b4 67c5c6cb

+3
+3
net/core/ethtool.c
··· 1457 1457 { 1458 1458 int err; 1459 1459 1460 + if (!dev->ethtool_ops->set_sg) 1461 + return -EOPNOTSUPP; 1462 + 1460 1463 if (data && !(dev->features & NETIF_F_ALL_CSUM)) 1461 1464 return -EINVAL; 1462 1465