Skip to content

Commit

Permalink
ethtool: __ethtool_set_sg: check for function pointer before using it
Browse files Browse the repository at this point in the history
__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>
  • Loading branch information
Roger Luethi authored and David S. Miller committed Mar 18, 2011
1 parent 67c5c6c commit 5e5069b
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions net/core/ethtool.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 5e5069b

Please sign in to comment.