From patchwork Sun May 15 07:21:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tariq Toukan X-Patchwork-Id: 9096281 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 383C2BF29F for ; Sun, 15 May 2016 07:22:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 64FFD20268 for ; Sun, 15 May 2016 07:22:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 82BDF2026C for ; Sun, 15 May 2016 07:22:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752082AbcEOHWY (ORCPT ); Sun, 15 May 2016 03:22:24 -0400 Received: from [193.47.165.129] ([193.47.165.129]:36002 "EHLO mellanox.co.il" rhost-flags-FAIL-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1752528AbcEOHWX (ORCPT ); Sun, 15 May 2016 03:22:23 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from tariqt@mellanox.com) with ESMTPS (AES256-SHA encrypted); 15 May 2016 10:21:55 +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 u4F7LtAa029920; Sun, 15 May 2016 10:21:55 +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 u4F7LtFX004410; Sun, 15 May 2016 10:21:55 +0300 Received: (from tariqt@localhost) by dev-l-vrt-207-006.mtl.labs.mlnx (8.14.7/8.14.7/Submit) id u4F7LoNn004409; Sun, 15 May 2016 10:21:50 +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: Sun, 15 May 2016 10:21:26 +0300 Message-Id: <1463296886-4364-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,