From patchwork Wed May 11 12:59:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tariq Toukan X-Patchwork-Id: 9096301 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E085DBF29F for ; Sun, 15 May 2016 07:53:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DE13420279 for ; Sun, 15 May 2016 07:53:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F346820274 for ; Sun, 15 May 2016 07:53:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752579AbcEOHxB (ORCPT ); Sun, 15 May 2016 03:53:01 -0400 Received: from [193.47.165.129] ([193.47.165.129]:43540 "EHLO mellanox.co.il" rhost-flags-FAIL-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1752389AbcEOHxB (ORCPT ); Sun, 15 May 2016 03:53:01 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from tariqt@mellanox.com) with ESMTPS (AES256-SHA encrypted); 15 May 2016 10:51:54 +0300 Received: from dev-l-vrt-207-006.mtl.labs.mlnx (dev-l-vrt-207-006.mtl.labs.mlnx [10.134.207.6]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id u4F7pscd004009; Sun, 15 May 2016 10:51:54 +0300 Received: from dev-l-vrt-207-006.mtl.labs.mlnx (localhost [127.0.0.1]) by dev-l-vrt-207-006.mtl.labs.mlnx (8.14.7/8.14.7) with ESMTP id u4F6pvKH002609; Sun, 15 May 2016 09:51:57 +0300 Received: (from tariqt@localhost) by dev-l-vrt-207-006.mtl.labs.mlnx (8.14.7/8.14.7/Submit) id u4BCxnAB029732; Wed, 11 May 2016 15:59:49 +0300 From: Tariq Toukan To: "David S. Miller" Cc: Dan Carpenter , linux-rdma@vger.kernel.org, netdev@vger.kernel.org, Eran Ben Elisha , Tariq Toukan Subject: [PATCH net] net/mlx4_core: Fix access to uninitialized index Date: Wed, 11 May 2016 15:59:37 +0300 Message-Id: <1462971577-29692-1-git-send-email-tariqt@mellanox.com> X-Mailer: git-send-email 1.8.4.3 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Prevent using uninitialized or negative index when handling steering entries. Fixes: b12d93d63c32 ('mlx4: Add support for promiscuous mode in the new steering model.') Signed-off-by: Tariq Toukan Reported-by: Dan Carpenter --- drivers/net/ethernet/mellanox/mlx4/mcg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx4/mcg.c b/drivers/net/ethernet/mellanox/mlx4/mcg.c index 6aa7397..f2d0920 100644 --- a/drivers/net/ethernet/mellanox/mlx4/mcg.c +++ b/drivers/net/ethernet/mellanox/mlx4/mcg.c @@ -1102,7 +1102,7 @@ int mlx4_qp_attach_common(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16], struct mlx4_cmd_mailbox *mailbox; struct mlx4_mgm *mgm; u32 members_count; - int index, prev; + int index = -1, prev; int link = 0; int i; int err; @@ -1181,7 +1181,7 @@ int mlx4_qp_attach_common(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16], goto out; out: - if (prot == MLX4_PROT_ETH) { + if (prot == MLX4_PROT_ETH && index != -1) { /* manage the steering entry for promisc mode */ if (new_entry) err = new_steering_entry(dev, port, steer,