From patchwork Fri Apr 8 22:07:22 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Duyck, Alexander H" X-Patchwork-Id: 90432 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 8926DB6F7D for ; Sat, 9 Apr 2011 08:07:33 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757666Ab1DHWHZ (ORCPT ); Fri, 8 Apr 2011 18:07:25 -0400 Received: from mga09.intel.com ([134.134.136.24]:10008 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757130Ab1DHWHY (ORCPT ); Fri, 8 Apr 2011 18:07:24 -0400 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP; 08 Apr 2011 15:07:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.63,326,1299484800"; d="scan'208";a="625765017" Received: from gitlad.jf.intel.com ([10.23.23.37]) by orsmga002.jf.intel.com with ESMTP; 08 Apr 2011 15:07:23 -0700 Received: from gitlad.jf.intel.com (gitlad.jf.intel.com [127.0.0.1]) by gitlad.jf.intel.com (8.14.2/8.14.2) with ESMTP id p38M7Mtm026602; Fri, 8 Apr 2011 15:07:22 -0700 From: Alexander Duyck Subject: [net-next-2.6 PATCH 1/2] ethtool: prevent null pointer dereference with NTUPLE set but no set_rx_ntuple To: davem@davemloft.net, jeffrey.t.kirsher@intel.com, bhutchings@solarflare.com Cc: netdev@vger.kernel.org Date: Fri, 08 Apr 2011 15:07:22 -0700 Message-ID: <20110408220722.25468.98089.stgit@gitlad.jf.intel.com> In-Reply-To: <20110408220410.25468.49130.stgit@gitlad.jf.intel.com> References: <20110408220410.25468.49130.stgit@gitlad.jf.intel.com> User-Agent: StGIT/0.14.2 MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 --- net/core/ethtool.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/net/core/ethtool.c b/net/core/ethtool.c index 1b7fa98..704e176 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;