From patchwork Mon Nov 1 17:53:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harman Kalra X-Patchwork-Id: 103358 X-Patchwork-Delegate: david.marchand@redhat.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 A6A39A0548; Mon, 1 Nov 2021 18:53:48 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 775F140E28; Mon, 1 Nov 2021 18:53:48 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 019D340DF6 for ; Mon, 1 Nov 2021 18:53:46 +0100 (CET) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 1A1CPxSt000810; Mon, 1 Nov 2021 10:53:46 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : mime-version : content-type; s=pfpt0220; bh=DlHjCVPiYKLB7TdFgodgiB1iazQg2tv+Va1rb+8Wua4=; b=WKQgvDIGTBwd/xn6SGEY/oiDUGweT8wPUq4ZsDs2V9FGYh/LYV7o2bR52UkU5iynT83y 9jcvSgmezOIr5GITjgwGnqZU0+BUjJZRpHg+IXEhbSUgxb5C9ZamJQCxph+4DOtzcB3n yi+tNVh2bBvJV5AgWYL15Wrr9qv364D7JuXg2w3m0I9dcrYptGvaII2MxT3L83mEx6N/ TJeaeV2edqfpnYOfWf9TWsz6QFJb/gi0wXIppkq7O3MR3UrfKBvQiBf/SfkRxCgjwcqO Q8bGEI2LGU6b1P8DDIMH0JkfCCf5SSTHmdBVSog584YLhrWqIeJbpnYWzM5w2Wip4CVN uw== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3c25c4bsbk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 01 Nov 2021 10:53:46 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Mon, 1 Nov 2021 10:53:44 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.18 via Frontend Transport; Mon, 1 Nov 2021 10:53:44 -0700 Received: from localhost.marvell.com (unknown [10.29.52.211]) by maili.marvell.com (Postfix) with ESMTP id D62213F70B7; Mon, 1 Nov 2021 10:53:42 -0700 (PDT) From: Harman Kalra To: , Harman Kalra CC: , Date: Mon, 1 Nov 2021 23:23:32 +0530 Message-ID: <20211101175337.83358-1-hkalra@marvell.com> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: Hn6JF7OM_MDZTE03G-CQQ3SpPpCIgfhs X-Proofpoint-GUID: Hn6JF7OM_MDZTE03G-CQQ3SpPpCIgfhs X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.0.607.475 definitions=2021-11-01_06,2021-11-01_01,2020-04-07_01 Subject: [dpdk-dev] [PATCH 1/6] interrupts: fix argument cannot be negative 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" This patch fixes coverity issues by adding a check for negative event fd value. Coverity issue: 373716,373699,373693,373688 Fixes: bbbac4cd6ed2 ("interrupts: remove direct access to interrupt handle") Signed-off-by: Harman Kalra --- lib/eal/linux/eal_interrupts.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/eal/linux/eal_interrupts.c b/lib/eal/linux/eal_interrupts.c index f72661e1f0..15a27a2abf 100644 --- a/lib/eal/linux/eal_interrupts.c +++ b/lib/eal/linux/eal_interrupts.c @@ -416,7 +416,7 @@ uio_intx_intr_disable(const struct rte_intr_handle *intr_handle) /* use UIO config file descriptor for uio_pci_generic */ uio_cfg_fd = rte_intr_dev_fd_get(intr_handle); - if (pread(uio_cfg_fd, &command_high, 1, 5) != 1) { + if (uio_cfg_fd < 0 || pread(uio_cfg_fd, &command_high, 1, 5) != 1) { RTE_LOG(ERR, EAL, "Error reading interrupts status for fd %d\n", uio_cfg_fd); @@ -442,7 +442,7 @@ uio_intx_intr_enable(const struct rte_intr_handle *intr_handle) /* use UIO config file descriptor for uio_pci_generic */ uio_cfg_fd = rte_intr_dev_fd_get(intr_handle); - if (pread(uio_cfg_fd, &command_high, 1, 5) != 1) { + if (uio_cfg_fd < 0 || pread(uio_cfg_fd, &command_high, 1, 5) != 1) { RTE_LOG(ERR, EAL, "Error reading interrupts status for fd %d\n", uio_cfg_fd); @@ -465,7 +465,8 @@ uio_intr_disable(const struct rte_intr_handle *intr_handle) { const int value = 0; - if (write(rte_intr_fd_get(intr_handle), &value, sizeof(value)) < 0) { + if (rte_intr_fd_get(intr_handle) < 0 || + write(rte_intr_fd_get(intr_handle), &value, sizeof(value)) < 0) { RTE_LOG(ERR, EAL, "Error disabling interrupts for fd %d (%s)\n", rte_intr_fd_get(intr_handle), strerror(errno)); return -1; @@ -478,7 +479,8 @@ uio_intr_enable(const struct rte_intr_handle *intr_handle) { const int value = 1; - if (write(rte_intr_fd_get(intr_handle), &value, sizeof(value)) < 0) { + if (rte_intr_fd_get(intr_handle) < 0 || + write(rte_intr_fd_get(intr_handle), &value, sizeof(value)) < 0) { RTE_LOG(ERR, EAL, "Error enabling interrupts for fd %d (%s)\n", rte_intr_fd_get(intr_handle), strerror(errno)); return -1;