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 2AE89A00C5; Sun, 26 Apr 2020 15:01:09 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 04B421BF75; Sun, 26 Apr 2020 15:01:08 +0200 (CEST) Received: from huawei.com (szxga05-in.huawei.com [45.249.212.191]) by dpdk.org (Postfix) with ESMTP id 070C91BF72; Sun, 26 Apr 2020 15:01:05 +0200 (CEST) Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 7B6EFC73022C13A39BEF; Sun, 26 Apr 2020 21:01:04 +0800 (CST) Received: from localhost (10.173.251.152) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.487.0; Sun, 26 Apr 2020 21:00:58 +0800 From: wangyunjian To: CC: , , , , Yunjian Wang , Date: Sun, 26 Apr 2020 21:00:52 +0800 Message-ID: <1587906052-1548-1-git-send-email-wangyunjian@huawei.com> X-Mailer: git-send-email 1.9.5.msysgit.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.173.251.152] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH] crypto/caam_jr: fix wrong check of fd 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: Yunjian Wang Zero is a valid fd. It will fail to check the fd if the fd is zero. Fixes: e7a45f3cc245 ("crypto/caam_jr: add UIO specific operations") Cc: stable@dpdk.org Signed-off-by: Yunjian Wang --- drivers/crypto/caam_jr/caam_jr_uio.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/crypto/caam_jr/caam_jr_uio.c b/drivers/crypto/caam_jr/caam_jr_uio.c index b1bb44ca4..658de5460 100644 --- a/drivers/crypto/caam_jr/caam_jr_uio.c +++ b/drivers/crypto/caam_jr/caam_jr_uio.c @@ -145,7 +145,7 @@ file_read_first_line(const char root[], const char subdir[], "%s/%s/%s", root, subdir, filename); fd = open(absolute_file_name, O_RDONLY); - SEC_ASSERT(fd > 0, fd, "Error opening file %s", + SEC_ASSERT(fd >= 0, fd, "Error opening file %s", absolute_file_name); /* read UIO device name from first line in file */ @@ -389,7 +389,7 @@ uio_job_ring *config_job_ring(void) /* Open device file */ job_ring->uio_fd = open(uio_device_file_name, O_RDWR); - SEC_ASSERT(job_ring->uio_fd > 0, NULL, + SEC_ASSERT(job_ring->uio_fd >= 0, NULL, "Failed to open UIO device file for job ring %d", job_ring->jr_id); @@ -488,7 +488,7 @@ sec_cleanup(void) /* I need to close the fd after shutdown UIO commands need to be * sent using the fd */ - if (job_ring->uio_fd != 0) { + if (job_ring->uio_fd >= 0) { CAAM_JR_INFO( "Closed device file for job ring %d , fd = %d", job_ring->jr_id, job_ring->uio_fd); -- 2.19.1