From patchwork Mon Oct 25 12:56:47 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Cohen X-Patchwork-Id: 266902 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o9PCuNbd023847 for ; Mon, 25 Oct 2010 12:56:23 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755421Ab0JYM4W (ORCPT ); Mon, 25 Oct 2010 08:56:22 -0400 Received: from mail-bw0-f46.google.com ([209.85.214.46]:56298 "EHLO mail-bw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755263Ab0JYM4W (ORCPT ); Mon, 25 Oct 2010 08:56:22 -0400 Received: by bwz11 with SMTP id 11so2312106bwz.19 for ; Mon, 25 Oct 2010 05:56:19 -0700 (PDT) Received: by 10.204.49.208 with SMTP id w16mr5232081bkf.35.1288011379335; Mon, 25 Oct 2010 05:56:19 -0700 (PDT) Received: from localhost ([82.166.227.17]) by mx.google.com with ESMTPS id t10sm4798471bkj.16.2010.10.25.05.56.17 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 25 Oct 2010 05:56:18 -0700 (PDT) Date: Mon, 25 Oct 2010 14:56:47 +0200 From: Eli Cohen To: davem@davemloft.net, yevgenyp@mellanox.co.il Cc: Roland Dreier , RDMA list , netdev@vger.kernel.org Subject: [PATCH] mlx4_en: Fix out of bounds array access Message-ID: <20101025125647.GA7710@mtldesk30> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Mon, 25 Oct 2010 12:56:23 +0000 (UTC) diff --git a/drivers/net/mlx4/port.c b/drivers/net/mlx4/port.c index 56371ef..4513395 100644 --- a/drivers/net/mlx4/port.c +++ b/drivers/net/mlx4/port.c @@ -111,6 +111,12 @@ int mlx4_register_mac(struct mlx4_dev *dev, u8 port, u64 mac, int *index) goto out; } } + + if (free < 0) { + err = -ENOMEM; + goto out; + } + mlx4_dbg(dev, "Free MAC index is %d\n", free); if (table->total == table->max) { @@ -224,6 +230,11 @@ int mlx4_register_vlan(struct mlx4_dev *dev, u8 port, u16 vlan, int *index) } } + if (free < 0) { + err = -ENOMEM; + goto out; + } + if (table->total == table->max) { /* No free vlan entries */ err = -ENOSPC;