All of lore.kernel.org
 help / color / mirror / Atom feed
From: Amir Vadai <amirv@mellanox.com>
To: "David S. Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org, Or Gerlitz <ogerlitz@mellanox.com>,
	Yevgeny Petrilin <yevgenyp@mellanox.com>,
	Amir Vadai <amirv@mellanox.com>,
	Eugenia Emantayev <eugenia@mellanox.com>,
	Eli Cohen <eli@mellanox.com>
Subject: [PATCH net-next 3/6] net/mlx4: Verify port number in __mlx4_unregister_mac
Date: Tue,  8 Jul 2014 11:25:21 +0300	[thread overview]
Message-ID: <1404807924-29038-4-git-send-email-amirv@mellanox.com> (raw)
In-Reply-To: <1404807924-29038-1-git-send-email-amirv@mellanox.com>

From: Eugenia Emantayev <eugenia@mellanox.com>

Verify port number to avoid crashes if port number is outside the range.


Signed-off-by: Eli Cohen <eli@mellanox.com>
Signed-off-by: Eugenia Emantayev <eugenia@mellanox.com>
Signed-off-by: Amir Vadai <amirv@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlx4/port.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/port.c b/drivers/net/ethernet/mellanox/mlx4/port.c
index 5d76a60..9ba0c1c 100644
--- a/drivers/net/ethernet/mellanox/mlx4/port.c
+++ b/drivers/net/ethernet/mellanox/mlx4/port.c
@@ -244,10 +244,16 @@ EXPORT_SYMBOL_GPL(mlx4_get_base_qpn);
 
 void __mlx4_unregister_mac(struct mlx4_dev *dev, u8 port, u64 mac)
 {
-	struct mlx4_port_info *info = &mlx4_priv(dev)->port[port];
-	struct mlx4_mac_table *table = &info->mac_table;
+	struct mlx4_port_info *info;
+	struct mlx4_mac_table *table;
 	int index;
 
+	if (port < 1 || port > dev->caps.num_ports) {
+		mlx4_warn(dev, "invalid port number (%d), aborting...\n", port);
+		return;
+	}
+	info = &mlx4_priv(dev)->port[port];
+	table = &info->mac_table;
 	mutex_lock(&table->mutex);
 	index = find_index(dev, table, mac);
 
-- 
1.8.3.4

  parent reply	other threads:[~2014-07-08  8:26 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-08  8:25 [PATCH net-next 0/6] Mellanox driver update Jul-08-2014 Amir Vadai
2014-07-08  8:25 ` [PATCH net-next 1/6] net/mlx4_en: Fix set port ratelimit for 40GE Amir Vadai
2014-07-08  8:25 ` [PATCH net-next 2/6] net/mlx4_en: Run loopback test only when port is up Amir Vadai
2014-07-08  8:25 ` Amir Vadai [this message]
2014-07-08  8:25 ` [PATCH net-next 4/6] net/mlx4_en: Do not disable vlan filter during promiscuous mode Amir Vadai
2014-07-08  8:25 ` [PATCH net-next 5/6] net/mlx4_en: Do not count LLC/SNAP in MTU calculation Amir Vadai
2014-07-08  8:25 ` [PATCH net-next 6/6] net/mlx4_en: Fix mac_hash database inconsistency Amir Vadai
2014-07-09  2:59 ` [PATCH net-next 0/6] Mellanox driver update Jul-08-2014 David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1404807924-29038-4-git-send-email-amirv@mellanox.com \
    --to=amirv@mellanox.com \
    --cc=davem@davemloft.net \
    --cc=eli@mellanox.com \
    --cc=eugenia@mellanox.com \
    --cc=netdev@vger.kernel.org \
    --cc=ogerlitz@mellanox.com \
    --cc=yevgenyp@mellanox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.