From: Alexander Duyck Date: Fri, 8 Apr 2011 12:07:22 +0000 (+0000) Subject: ethtool: prevent null pointer dereference with NTUPLE set but no set_rx_ntuple X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=5d9f11cf5038587cc53975deb8beaa1a876a7a7b;p=openwrt%2Fstaging%2Fblogic.git ethtool: prevent null pointer dereference with NTUPLE set but no set_rx_ntuple This change is meant to prevent a possible null pointer dereference if NETIF_F_NTUPLE is defined but the set_rx_ntuple function pointer is not. The main motivation behind this patch is to eventually replace the ntuple interfaces entirely with the network flow classifier interfaces. This allows the device drivers to maintain the ntuple check internally while using the network flow classifier interface for setting up and displaying rules. Signed-off-by: Alexander Duyck Signed-off-by: David S. Miller --- diff --git a/net/core/ethtool.c b/net/core/ethtool.c index 1b7fa984de7d..704e176ad3a9 100644 --- a/net/core/ethtool.c +++ b/net/core/ethtool.c @@ -910,6 +910,9 @@ static noinline_for_stack int ethtool_set_rx_ntuple(struct net_device *dev, struct ethtool_rx_ntuple_flow_spec_container *fsc = NULL; int ret; + if (!ops->set_rx_ntuple) + return -EOPNOTSUPP; + if (!(dev->features & NETIF_F_NTUPLE)) return -EINVAL;