From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9616FA04F1; Fri, 13 Dec 2019 15:14:23 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E4B541BFBE; Fri, 13 Dec 2019 15:13:50 +0100 (CET) Received: from mail-pg1-f194.google.com (mail-pg1-f194.google.com [209.85.215.194]) by dpdk.org (Postfix) with ESMTP id 5FD601BFB9 for ; Fri, 13 Dec 2019 15:13:50 +0100 (CET) Received: by mail-pg1-f194.google.com with SMTP id x7so1624636pgl.11 for ; Fri, 13 Dec 2019 06:13:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=x4zIxgabGAOEyRZ1VqIzCzBD5OeB198V44ZJEIgC3KM=; b=YS+fHI6j1HwKuHwxBeoI+sByGlNap6F8uRGmbW4LMecyVw6cQ5KPsyvPCjssWGYL0G PI4bVt45R1/ujMTcKzZbsBV1ZyLwbfOlUBxtoYQ61PzJGAlDIB+NHUCo+A/CLhwmdHov aGGyMGLgAaiiCh4oDu8qPrahHmTHvhj935CtvCzVQ9uSjnrkPuPMDdFffPt1CcAEwDgf dnyLDLA5Urcghk+Pv0DUs0IdPn8p77W+emMQcKWdsEvK3UTZURlKXsBTBV5WWgx8w3vz KjDRqTYPe1AnxGl6gREUMECnUzNNJ+8fKQjlDMg6cvfnkibY6sBRl3UyKIwcR0hackd9 DVTw== 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=x4zIxgabGAOEyRZ1VqIzCzBD5OeB198V44ZJEIgC3KM=; b=UZWpIeGMBgmXgEry+ygE5TFoYpHdlV7l+7LIl2l267IEf3FXZT/LZyascgsZPGjECD 77Z7oSakOjYo6AfUalGIulYI5Oj0Nr8NdyBKByWGI10th7L9/o/2I/f/5BmDnEdjPZVY y2vFXZLr+fzpjQCUoXn9KazxUYfPyyrikte9n7fyifozF6Koh9+68WdFyuEsWYTkWzf5 Urm/foL9zcgrlXOb9m22R3bm8LnuX/w7TGXZWlgg1yZGztVVdcaYvnN9uTrV1iTM1mHb NfWs0/7iCzX0ys+/L8yWqzb4K7xkQBGo4WZ8RaSekluVjKJjbp5EQ+hXfKIVCwYOs8r3 71xA== X-Gm-Message-State: APjAAAVF/8pfkqd4b0zRhBDP1oRDicVt5ifQz+gVOBPuxnrmqkNVbJxB VUfmK+lTuqeYTCoR+aZgxQQ= X-Google-Smtp-Source: APXvYqwoG+w+EpnXo5C1LAIWsxFf+Ot8wJuWzTuDnFZsNtryiIxl+H3L9WoiRk0QsBv1ogDFTKRtXQ== X-Received: by 2002:a62:e817:: with SMTP id c23mr16365238pfi.24.1576246429724; Fri, 13 Dec 2019 06:13:49 -0800 (PST) Received: from local.opencloud.tech.localdomain ([203.100.54.194]) by smtp.gmail.com with ESMTPSA id b2sm12282589pff.6.2019.12.13.06.13.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Dec 2019 06:13:49 -0800 (PST) From: xiangxia.m.yue@gmail.com To: matan@mellanox.com, shahafs@mellanox.com Cc: dev@dpdk.org, Tonghao Zhang , Suanming Mou Date: Fri, 13 Dec 2019 22:13:36 +0800 Message-Id: <1576246416-31324-1-git-send-email-xiangxia.m.yue@gmail.com> X-Mailer: git-send-email 1.8.3.1 Subject: [dpdk-dev] [PATCH] net/mlx5: avoid crash when meter action conf is NULL 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Tonghao Zhang When offloading the meter, should check the action conf and make sure it is valid. Fixes: f46bf7488705 ("net/mlx5: support meter flow action") Cc: Suanming Mou Signed-off-by: Tonghao Zhang --- drivers/net/mlx5/mlx5_flow_dv.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index 73aaea4..2c47382 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -3402,7 +3402,12 @@ struct field_modify_info modify_tcp[] = { { struct mlx5_priv *priv = dev->data->dev_private; const struct rte_flow_action_meter *am = action->conf; - struct mlx5_flow_meter *fm = mlx5_flow_meter_find(priv, am->mtr_id); + struct mlx5_flow_meter *fm; + + if (!am) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION, NULL, + "meter action conf is NULL"); if (action_flags & MLX5_FLOW_ACTION_METER) return rte_flow_error_set(error, ENOTSUP, @@ -3417,6 +3422,8 @@ struct field_modify_info modify_tcp[] = { RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, "meter action not supported"); + + fm = mlx5_flow_meter_find(priv, am->mtr_id); if (!fm) return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, NULL, -- 1.8.3.1