From patchwork Wed Jun 20 10:52:58 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: santosh nayak X-Patchwork-Id: 166001 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 83F0BB6FFC for ; Wed, 20 Jun 2012 20:53:21 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756520Ab2FTKxT (ORCPT ); Wed, 20 Jun 2012 06:53:19 -0400 Received: from mail-pb0-f46.google.com ([209.85.160.46]:55252 "EHLO mail-pb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756386Ab2FTKxR (ORCPT ); Wed, 20 Jun 2012 06:53:17 -0400 Received: by pbbrp8 with SMTP id rp8so461319pbb.19 for ; Wed, 20 Jun 2012 03:53:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer; bh=CdBLE4d4MmjUAIpGz33a4IJRQ/UgjetHwEbZ4qbJz2Y=; b=DbmsQ3/d5qRBh9VmqE+3cYqhEpbNdHdvZhw2gdYycEih6fvAyPmImqXYAQCSzkEooh GuMdyB0040STiwHhI08Z2+xT8H9QhF//v/PPpVrhoxox/U0iddX2w0Y3cHmXfyy33UVm S6etK8mNEQyygM+BvRNiieGG5JwXJqHPZnNvAoWNbqYlCe0Ln9y97xap3Xb2ZnIVlCmv +wKLmhpfcoIAJOrWRj0ofHINbXnA+YRSBDDF9xq9NoiQY+UO9w99aD5N5L6uklq29h4w fnpILfl9AznrvCRBycv8G5wQUPj718Vlh9g4nYRuNWLQWKczixPtNfmD6vviwxp/yJ2E Lbfg== Received: by 10.68.197.198 with SMTP id iw6mr73425962pbc.36.1340189596932; Wed, 20 Jun 2012 03:53:16 -0700 (PDT) Received: from localhost.localdomain ([64.103.156.72]) by mx.google.com with ESMTPS id rd7sm31494960pbc.70.2012.06.20.03.53.14 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 20 Jun 2012 03:53:16 -0700 (PDT) From: santosh nayak To: sony.chacko@qlogic.com, rajesh.borundia@qlogic.com Cc: netdev@vger.kernel.org, kernel-janitors@vger.kernel.org, Santosh Nayak Subject: [PATCH] netxen : Error return off by one for XG port. Date: Wed, 20 Jun 2012 16:22:58 +0530 Message-Id: <1340189578-18308-1-git-send-email-santoshprasadnayak@gmail.com> X-Mailer: git-send-email 1.7.4.4 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Santosh Nayak There are NETXEN_NIU_MAX_XG_PORTS ports. Port indexing starts from zero. Hence we should also return error for 'port == NETXEN_NIU_MAX_XG_PORTS'. Signed-off-by: Santosh Nayak --- .../ethernet/qlogic/netxen/netxen_nic_ethtool.c | 4 ++-- drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_ethtool.c b/drivers/net/ethernet/qlogic/netxen/netxen_nic_ethtool.c index d4f179f..9103e3e 100644 --- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_ethtool.c +++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_ethtool.c @@ -511,7 +511,7 @@ netxen_nic_get_pauseparam(struct net_device *dev, break; } } else if (adapter->ahw.port_type == NETXEN_NIC_XGBE) { - if ((port < 0) || (port > NETXEN_NIU_MAX_XG_PORTS)) + if ((port < 0) || (port >= NETXEN_NIU_MAX_XG_PORTS)) return; pause->rx_pause = 1; val = NXRD32(adapter, NETXEN_NIU_XG_PAUSE_CTL); @@ -577,7 +577,7 @@ netxen_nic_set_pauseparam(struct net_device *dev, } NXWR32(adapter, NETXEN_NIU_GB_PAUSE_CTL, val); } else if (adapter->ahw.port_type == NETXEN_NIC_XGBE) { - if ((port < 0) || (port > NETXEN_NIU_MAX_XG_PORTS)) + if ((port < 0) || (port >= NETXEN_NIU_MAX_XG_PORTS)) return -EIO; val = NXRD32(adapter, NETXEN_NIU_XG_PAUSE_CTL); if (port == 0) { diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c b/drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c index de96a94..946160f 100644 --- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c +++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c @@ -365,7 +365,7 @@ static int netxen_niu_disable_xg_port(struct netxen_adapter *adapter) if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) return 0; - if (port > NETXEN_NIU_MAX_XG_PORTS) + if (port >= NETXEN_NIU_MAX_XG_PORTS) return -EINVAL; mac_cfg = 0; @@ -392,7 +392,7 @@ static int netxen_p2_nic_set_promisc(struct netxen_adapter *adapter, u32 mode) u32 port = adapter->physical_port; u16 board_type = adapter->ahw.board_type; - if (port > NETXEN_NIU_MAX_XG_PORTS) + if (port >= NETXEN_NIU_MAX_XG_PORTS) return -EINVAL; mac_cfg = NXRD32(adapter, NETXEN_NIU_XGE_CONFIG_0 + (0x10000 * port));