From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f67.google.com (mail-wm0-f67.google.com [74.125.82.67]) by dpdk.org (Postfix) with ESMTP id 047E51B1F8 for ; Thu, 2 Nov 2017 14:30:06 +0100 (CET) Received: by mail-wm0-f67.google.com with SMTP id b9so11464645wmh.0 for ; Thu, 02 Nov 2017 06:30:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=bckKe/kBHkKXlqSolqYvfbbUkzv+VP8L/vgXiaP8Xm4=; b=c1Xozs6yGcyW++RB5ITQDe3mPepOduBEz56JMNqCbXAkK+cX8QVTc9aYB9P1auozBQ aCz2CaHJos64wxoVcdVv9gPxsBYFtJZbxgl68Gygixz5+USSPUzElpN8uCUAxQklb8od dF6ELKXjdfJZ9Gx57hnyPMbT4IqrA1eTWmbFgO5CVDofCN3MmOt7lB/sQJVAhX4dem9y zyStzvi4emkkpsspDujg9eJChv+1iW0+/i11vkOd07jcRVoE32azYV5jywu7pYWQUgEh bPgSgh+UmpMM/vDzis2zKCvLyLix5Grc+lRpu4EMGdp9krJW7dQ5y3Iw75uf5qubLINp r+Rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=bckKe/kBHkKXlqSolqYvfbbUkzv+VP8L/vgXiaP8Xm4=; b=Sq8E3MQqmsvtBrdR+rqXZFs7Nxn9tOhNB66YZTuK1/quM8OOSNAG/iGeyGg78wFIKp 8aa74IDGxri+gQxtL11jZaX/wEB62EYuiarlXmFf57+BpVwEgE+Eu8SN/e2od3iggsgm yR0oIrwXx4c2K4U6nZFT3+c8F9iIe0gkmDrMAKKP6gIrZUG6TvMfilHUXmIK2iaiTXEB M7SvCqayNjYXqmoxlzhc6SGg4k/qJbuTo9yXRsz0sxMZBTT5x14ptKia/L4an2BhIKBV Xg+qYi2jZZ7BBoxPVRVg/YDaqUDOXHB4UXmn1EB3peYDm3gTOZLT5VMwxbkUGAWkX5fN dFGA== X-Gm-Message-State: AMCzsaVjcdteNhSl+dAUC29q8IOG9mDj17R2k6tmZOZTxfYr0lIrqhdg n+yF2uZDoGHzd9ABX6x6cX0tjcUJew== X-Google-Smtp-Source: ABhQp+SY3FBX6JcxaYdUotQwwV6ekp4nHDXCweweLCN/9WHLlPjhWWvdp/1iKnEpjEdlTgs4vj/HSA== X-Received: by 10.80.152.229 with SMTP id j92mr4589486edb.279.1509629406478; Thu, 02 Nov 2017 06:30:06 -0700 (PDT) Received: from laranjeiro-vm.dev.6wind.com. (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id 33sm3838401edt.75.2017.11.02.06.30.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Nov 2017 06:30:06 -0700 (PDT) From: Nelio Laranjeiro To: dev@dpdk.org Cc: Yongseok Koh , Adrien Mazarguil Date: Thu, 2 Nov 2017 14:30:03 +0100 Message-Id: X-Mailer: git-send-email 2.11.0 Subject: [dpdk-dev] [PATCH] net/mlx5: fix segfault due to array overflow X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 Nov 2017 13:30:07 -0000 VLAN id is limited to MLX5_MAX_VLAN_IDS which is not verified by the code before trying to add a new VLAN filter. Fixes: 272733b5ebfd ("net/mlx5: use flow to enable unicast traffic") Signed-off-by: Nelio Laranjeiro --- drivers/net/mlx5/mlx5_vlan.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/net/mlx5/mlx5_vlan.c b/drivers/net/mlx5/mlx5_vlan.c index 89874aabd..6fc315ef3 100644 --- a/drivers/net/mlx5/mlx5_vlan.c +++ b/drivers/net/mlx5/mlx5_vlan.c @@ -61,6 +61,7 @@ mlx5_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on) { struct priv *priv = dev->data->dev_private; unsigned int i; + int ret = 0; priv_lock(priv); DEBUG("%p: %s VLAN filter ID %" PRIu16, @@ -69,6 +70,11 @@ mlx5_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on) for (i = 0; (i != priv->vlan_filter_n); ++i) if (priv->vlan_filter[i] == vlan_id) break; + /* Check if there's room for another VLAN filter. */ + if (i == RTE_DIM(priv->vlan_filter)) { + ret = -ENOMEM; + goto out; + } if (i < priv->vlan_filter_n) { assert(priv->vlan_filter_n != 0); /* Enabling an existing VLAN filter has no effect. */ @@ -94,7 +100,7 @@ mlx5_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on) priv_dev_traffic_restart(priv, dev); out: priv_unlock(priv); - return 0; + return ret; } /** -- 2.11.0