From patchwork Sat Mar 27 07:38:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "humin (Q)" X-Patchwork-Id: 89958 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7D2B7A0A02; Sat, 27 Mar 2021 08:37:55 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3E89F140D90; Sat, 27 Mar 2021 08:37:51 +0100 (CET) Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) by mails.dpdk.org (Postfix) with ESMTP id 0F8D840686 for ; Sat, 27 Mar 2021 08:37:49 +0100 (CET) Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4F6rH45QCnz93y8; Sat, 27 Mar 2021 15:35:44 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS401-HUB.china.huawei.com (10.3.19.201) with Microsoft SMTP Server id 14.3.498.0; Sat, 27 Mar 2021 15:37:42 +0800 From: "Min Hu (Connor)" To: CC: , , Date: Sat, 27 Mar 2021 15:38:08 +0800 Message-ID: <1616830688-65506-4-git-send-email-humin29@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1616830688-65506-1-git-send-email-humin29@huawei.com> References: <1616830688-65506-1-git-send-email-humin29@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH 3/3] ethdev: fix miss input validation when access EEPROM info 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 Sender: "dev" From: Chengchang Tang This patch adds validity check of input pointer in EEPROM dump API. Fixes: 7a3f27cbf59b ("ethdev: add access to specific device info") Cc: stable@dpdk.org Signed-off-by: Chengchang Tang Signed-off-by: Min Hu (Connor) Reviewed-by: Ferruh Yigit --- lib/librte_ethdev/rte_ethdev.c | 4 ++++ lib/librte_ethdev/rte_ethdev.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index 3fe200d..6b5cfd6 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -5312,6 +5312,8 @@ rte_eth_dev_get_eeprom(uint16_t port_id, struct rte_dev_eeprom_info *info) struct rte_eth_dev *dev; RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); + if (info == NULL) + return -EINVAL; dev = &rte_eth_devices[port_id]; RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->get_eeprom, -ENOTSUP); @@ -5324,6 +5326,8 @@ rte_eth_dev_set_eeprom(uint16_t port_id, struct rte_dev_eeprom_info *info) struct rte_eth_dev *dev; RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); + if (info == NULL) + return -EINVAL; dev = &rte_eth_devices[port_id]; RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->set_eeprom, -ENOTSUP); diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h index 5747307..1a0382e 100644 --- a/lib/librte_ethdev/rte_ethdev.h +++ b/lib/librte_ethdev/rte_ethdev.h @@ -4429,6 +4429,7 @@ int rte_eth_dev_get_eeprom_length(uint16_t port_id); * @return * - (0) if successful. * - (-ENOTSUP) if hardware doesn't support. + * - (-EINVAL) if bad parameter. * - (-ENODEV) if *port_id* invalid. * - (-EIO) if device is removed. * - others depends on the specific operations implementation. @@ -4490,6 +4491,7 @@ rte_eth_dev_get_module_info(uint16_t port_id, * @return * - (0) if successful. * - (-ENOTSUP) if hardware doesn't support. + * - (-EINVAL) if bad parameter. * - (-ENODEV) if *port_id* invalid. * - (-EIO) if device is removed. * - others depends on the specific operations implementation.