crypto/ccp: fix fd leak on probe failure

Message ID 1587882975-13960-1-git-send-email-wangyunjian@huawei.com (mailing list archive)
State Accepted, archived
Delegated to: akhil goyal
Headers
Series crypto/ccp: fix fd leak on probe failure |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-nxp-Performance success Performance Testing PASS
ci/Intel-compilation success Compilation OK
ci/iol-testing fail Testing issues
ci/iol-mellanox-Performance success Performance Testing PASS

Commit Message

Yunjian Wang April 26, 2020, 6:36 a.m. UTC
From: Yunjian Wang <wangyunjian@huawei.com>

Zero is a valid fd. When ccp_probe_device() is failed, the uio_fd won't be
closed thus leading fd leak.

Fixes: ef4b04f87fa6 ("crypto/ccp: support device init")
Cc: stable@dpdk.org

Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
---
 drivers/crypto/ccp/ccp_dev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Kumar, Ravi1 April 27, 2020, 4:10 a.m. UTC | #1
[AMD Public Use]

Acked-by: Ravi Kumar <ravi1.kumar@amd.com>
>-----Original Message-----
>From: wangyunjian <wangyunjian@huawei.com> 
>Sent: Sunday, April 26, 2020 12:06 PM
>To: dev@dpdk.org; Kumar, Ravi1 <Ravi1.Kumar@amd.com>
>Cc: jerry.lilijun@huawei.com; xudingke@huawei.com; Yunjian Wang <wangyunjian@huawei.com>; stable@dpdk.org
>Subject: [dpdk-dev] [PATCH] crypto/ccp: fix fd leak on probe failure
>
>
>From: Yunjian Wang <wangyunjian@huawei.com>
>
>Zero is a valid fd. When ccp_probe_device() is failed, the uio_fd won't be closed thus leading fd leak.
>
>Fixes: ef4b04f87fa6 ("crypto/ccp: support device init")
>Cc: stable@dpdk.org
>
>Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
>---
> drivers/crypto/ccp/ccp_dev.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/drivers/crypto/ccp/ccp_dev.c b/drivers/crypto/ccp/ccp_dev.c index 80fe6a453..7d98b2eb2 100644
>--- a/drivers/crypto/ccp/ccp_dev.c
>+++ b/drivers/crypto/ccp/ccp_dev.c
>@@ -760,7 +760,7 @@ ccp_probe_device(const char *dirname, uint16_t domain,
>        return 0;
> fail:
>        CCP_LOG_ERR("CCP Device probe failed");
>-       if (uio_fd > 0)
>+       if (uio_fd >= 0)
>                close(uio_fd);
>        if (ccp_dev)
>                rte_free(ccp_dev);
>--
>2.19.1
>
>
>
  
Akhil Goyal May 9, 2020, 9:52 p.m. UTC | #2
> 
> Acked-by: Ravi Kumar <ravi1.kumar@amd.com>
Applied to dpdk-next-crypto

Thanks.
  

Patch

diff --git a/drivers/crypto/ccp/ccp_dev.c b/drivers/crypto/ccp/ccp_dev.c
index 80fe6a453..7d98b2eb2 100644
--- a/drivers/crypto/ccp/ccp_dev.c
+++ b/drivers/crypto/ccp/ccp_dev.c
@@ -760,7 +760,7 @@  ccp_probe_device(const char *dirname, uint16_t domain,
 	return 0;
 fail:
 	CCP_LOG_ERR("CCP Device probe failed");
-	if (uio_fd > 0)
+	if (uio_fd >= 0)
 		close(uio_fd);
 	if (ccp_dev)
 		rte_free(ccp_dev);