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 781FCA0548; Mon, 1 Nov 2021 18:53:59 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6879F410E6; Mon, 1 Nov 2021 18:53:59 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 77C7840DF6 for ; Mon, 1 Nov 2021 18:53:57 +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 1A1HJ72W008746; Mon, 1 Nov 2021 10:53:57 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=pfpt0220; bh=05Gr7EUT1321WE+6rm1LFXpNWiR7Q3uYI9MC7ZRwjHQ=; b=ivGjeMzxjLZV/RBjjKIWuzlwP4Z+PUUJiuaCeHNgof9HlM0X6EWKXIBTHgNjK9PCgB+2 jJm8wtLnETEGmGtPC5CazFeLnPS4BU8wGj19jmWxO6C4kDfwls0LmsatSNiDFgm0rw5t N6iWmObLgs9O1HqY/Svm2P6nQ6/f2OQCnhs3G2p7+DW1s6NhSYCNxcnen5mvFO2OD418 7P0dDyXmyFuqo4aZD9ZSombzLhKHaLLH16aKnldZV98ib6lvIqnjfbkc8Lfo9oarBdx8 WIupGesU4DYTPMBanfQbn8eJO01x4rV3AcJoQljyWpnGM8c+WH3TrVBjme3hKWK7PZw7 gA== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3c25c4bsc2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 01 Nov 2021 10:53:56 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Mon, 1 Nov 2021 10:53:54 -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:54 -0700 Received: from localhost.marvell.com (unknown [10.29.52.211]) by maili.marvell.com (Postfix) with ESMTP id 6E2E73F70B3; Mon, 1 Nov 2021 10:53:53 -0700 (PDT) From: Harman Kalra To: CC: , , Harman Kalra Date: Mon, 1 Nov 2021 23:23:33 +0530 Message-ID: <20211101175337.83358-2-hkalra@marvell.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20211101175337.83358-1-hkalra@marvell.com> References: <20211101175337.83358-1-hkalra@marvell.com> MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-ORIG-GUID: Oi0DUtNS9jhbHcnedC6zoSo3Cr_iyvOB X-Proofpoint-GUID: Oi0DUtNS9jhbHcnedC6zoSo3Cr_iyvOB 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 2/6] lib: 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 issue by adding a check for negative event fd value. Coverity issue: 373711,373694 Fixes: c2bd9367e18f ("lib: remove direct access to interrupt handle") Signed-off-by: Harman Kalra --- lib/eal/linux/eal_dev.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/eal/linux/eal_dev.c b/lib/eal/linux/eal_dev.c index 06820a3666..607f18ebc2 100644 --- a/lib/eal/linux/eal_dev.c +++ b/lib/eal/linux/eal_dev.c @@ -217,8 +217,10 @@ static void dev_delayed_unregister(void *param) { rte_intr_callback_unregister(intr_handle, dev_uev_handler, param); - close(rte_intr_fd_get(intr_handle)); - rte_intr_fd_set(intr_handle, -1); + if (rte_intr_fd_get(intr_handle) >= 0) { + close(rte_intr_fd_get(intr_handle)); + rte_intr_fd_set(intr_handle, -1); + } } static void @@ -234,6 +236,9 @@ dev_uev_handler(__rte_unused void *param) memset(&uevent, 0, sizeof(struct rte_dev_event)); memset(buf, 0, EAL_UEV_MSG_LEN); + if (rte_intr_fd_get(intr_handle) < 0) + return; + ret = recv(rte_intr_fd_get(intr_handle), buf, EAL_UEV_MSG_LEN, MSG_DONTWAIT); if (ret < 0 && errno == EAGAIN) -- 2.18.0