From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 96FF642A13; Fri, 28 Apr 2023 12:27:43 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8E68942DBF; Fri, 28 Apr 2023 12:27:35 +0200 (CEST) Received: from agw.arknetworks.am (agw.arknetworks.am [79.141.165.80]) by mails.dpdk.org (Postfix) with ESMTP id 571DC42DAA for ; Fri, 28 Apr 2023 12:27:32 +0200 (CEST) Received: from localhost.localdomain (unknown [37.252.90.108]) (using TLSv1.3 with cipher TLS_CHACHA20_POLY1305_SHA256 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA512) (No client certificate requested) by agw.arknetworks.am (Postfix) with ESMTPSA id A2809E10B5; Fri, 28 Apr 2023 14:27:31 +0400 (+04) From: Denis Pryazhennikov To: dev@dpdk.org Cc: Ivan Malov , Viacheslav Galaktionov , Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko Subject: [RFC PATCH 2/3] ethdev: check that at least one FEC mode is specified Date: Fri, 28 Apr 2023 14:27:27 +0400 Message-Id: <20230428102728.51956-3-denis.pryazhennikov@arknetworks.am> X-Mailer: git-send-email 2.37.0 (Apple Git-136) In-Reply-To: <20230428102728.51956-1-denis.pryazhennikov@arknetworks.am> References: <20230428102728.51956-1-denis.pryazhennikov@arknetworks.am> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The behaviour is undefined in the rte_eth_fec_set() function when the fec_capa parameter is equal to zero. Add a check to handle this case. Signed-off-by: Denis Pryazhennikov Acked-by: Ivan Malov Acked-by: Viacheslav Galaktionov --- lib/ethdev/rte_ethdev.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c index 4d0325568322..d02ee161cf6d 100644 --- a/lib/ethdev/rte_ethdev.c +++ b/lib/ethdev/rte_ethdev.c @@ -4751,6 +4751,11 @@ rte_eth_fec_set(uint16_t port_id, uint32_t fec_capa) RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); dev = &rte_eth_devices[port_id]; + if (fec_capa == 0) { + RTE_ETHDEV_LOG(ERR, "At least one FEC mode should be specified\n"); + return -EINVAL; + } + if (*dev->dev_ops->fec_set == NULL) return -ENOTSUP; ret = eth_err(port_id, (*dev->dev_ops->fec_set)(dev, fec_capa)); -- 2.37.0 (Apple Git-136)