DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH v2] net/virtio-user: fix run close(0) and close callfd
  2020-12-11 16:14 [dpdk-dev] [PATCH v2] net/virtio-user: fix run close(0) and close callfd Jiawei Zhu
@ 2020-12-02 19:32 ` Jiawei Zhu
  2020-12-11 16:53 ` Jiawei Zhu
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 8+ messages in thread
From: Jiawei Zhu @ 2020-12-02 19:32 UTC (permalink / raw)
  To: dev

From: Jiawei Zhu <zhujiawei12@huawei.com>

When i < VIRTIO_MAX_VIRTQUEUES and j == i,
dev->callfds[i] and dev->kickfds[i] are default 0.
So it will close(0), close the standard input (stdin).
And when the code fails in kickfd creation,
it will leaves one callfd not closed.

Fixes: e6e7ad8b3024 ("net/virtio-user: move eventfd open/close into init/uninit")
Cc: stable@dpdk.org:

Signed-off-by: Jiawei Zhu <zhujiawei12@huawei.com>
---
v2:
* Add close callfd when fail in kickfd creation before break.
---
---
 drivers/net/virtio/virtio_user/virtio_user_dev.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c
index 053f026..e1cbad0 100644
--- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
@@ -276,6 +276,7 @@ int virtio_user_stop_device(struct virtio_user_dev *dev)
 		}
 		kickfd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK);
 		if (kickfd < 0) {
+			close(callfd);
 			PMD_DRV_LOG(ERR, "kickfd error, %s", strerror(errno));
 			break;
 		}
@@ -284,7 +285,7 @@ int virtio_user_stop_device(struct virtio_user_dev *dev)
 	}
 
 	if (i < VIRTIO_MAX_VIRTQUEUES) {
-		for (j = 0; j <= i; ++j) {
+		for (j = 0; j < i; ++j) {
 			close(dev->callfds[j]);
 			close(dev->kickfds[j]);
 		}
-- 
1.8.3.1



^ permalink raw reply	[flat|nested] 8+ messages in thread

* [dpdk-dev] [PATCH v2] net/virtio-user: fix run close(0) and close callfd
@ 2020-12-11 16:14 Jiawei Zhu
  2020-12-02 19:32 ` Jiawei Zhu
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Jiawei Zhu @ 2020-12-11 16:14 UTC (permalink / raw)
  To: dev; +Cc: liweifeng2, zhujiawei12, maxime.coquelin, chenbo.xia

From: Jiawei Zhu <zhujiawei12@huawei.com>

When i < VIRTIO_MAX_VIRTQUEUES and j == i,
dev->callfds[i] and dev->kickfds[i] are default 0.
So it will close(0), close the standard input (stdin).
And when the code fails in kickfd creationg,
it will leaves one callfd not closed.

Fixes: e6e7ad8b3024 ("net/virtio-user: move eventfd open/close into init/uninit")
Cc: stable@dpdk.org:

Signed-off-by: Jiawei Zhu <17826875952@163.com>
---
v2:
* Add close callfd when fail in kickfd creation before break.
---
---
 drivers/net/virtio/virtio_user/virtio_user_dev.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c
index 053f026..e1cbad0 100644
--- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
@@ -276,6 +276,7 @@ int virtio_user_stop_device(struct virtio_user_dev *dev)
 		}
 		kickfd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK);
 		if (kickfd < 0) {
+			close(callfd);
 			PMD_DRV_LOG(ERR, "kickfd error, %s", strerror(errno));
 			break;
 		}
@@ -284,7 +285,7 @@ int virtio_user_stop_device(struct virtio_user_dev *dev)
 	}
 
 	if (i < VIRTIO_MAX_VIRTQUEUES) {
-		for (j = 0; j <= i; ++j) {
+		for (j = 0; j < i; ++j) {
 			close(dev->callfds[j]);
 			close(dev->kickfds[j]);
 		}
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [dpdk-dev] [PATCH v2] net/virtio-user: fix run close(0) and close callfd
  2020-12-11 16:14 [dpdk-dev] [PATCH v2] net/virtio-user: fix run close(0) and close callfd Jiawei Zhu
  2020-12-02 19:32 ` Jiawei Zhu
@ 2020-12-11 16:53 ` Jiawei Zhu
  2020-12-14 13:02   ` Xia, Chenbo
  2020-12-11 17:08 ` Jiawei Zhu
  2020-12-11 17:11 ` Jiawei Zhu
  3 siblings, 1 reply; 8+ messages in thread
From: Jiawei Zhu @ 2020-12-11 16:53 UTC (permalink / raw)
  To: dev

From: Jiawei Zhu <zhujiawei12@huawei.com>

When i < VIRTIO_MAX_VIRTQUEUES and j == i,
dev->callfds[i] and dev->kickfds[i] are default 0.
So it will close(0), close the standard input (stdin).
And when the code fails in kickfd creation,
it will leaves one callfd not closed.

Fixes: e6e7ad8b3024 ("net/virtio-user: move eventfd open/close into init/uninit")
Cc: stable@dpdk.org:

Signed-off-by: Jiawei Zhu <zhujiawei12@huawei.com>
---
v2:
* Add close callfd when fail in kickfd creation before break.
---
---
 drivers/net/virtio/virtio_user/virtio_user_dev.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c
index 053f026..e1cbad0 100644
--- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
@@ -276,6 +276,7 @@ int virtio_user_stop_device(struct virtio_user_dev *dev)
 		}
 		kickfd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK);
 		if (kickfd < 0) {
+			close(callfd);
 			PMD_DRV_LOG(ERR, "kickfd error, %s", strerror(errno));
 			break;
 		}
@@ -284,7 +285,7 @@ int virtio_user_stop_device(struct virtio_user_dev *dev)
 	}
 
 	if (i < VIRTIO_MAX_VIRTQUEUES) {
-		for (j = 0; j <= i; ++j) {
+		for (j = 0; j < i; ++j) {
 			close(dev->callfds[j]);
 			close(dev->kickfds[j]);
 		}
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [dpdk-dev] [PATCH v2] net/virtio-user: fix run close(0) and close callfd
  2020-12-11 16:14 [dpdk-dev] [PATCH v2] net/virtio-user: fix run close(0) and close callfd Jiawei Zhu
  2020-12-02 19:32 ` Jiawei Zhu
  2020-12-11 16:53 ` Jiawei Zhu
@ 2020-12-11 17:08 ` Jiawei Zhu
  2020-12-11 17:11 ` Jiawei Zhu
  3 siblings, 0 replies; 8+ messages in thread
From: Jiawei Zhu @ 2020-12-11 17:08 UTC (permalink / raw)
  To: dev

From: Jiawei Zhu <zhujiawei12@huawei.com>

When i < VIRTIO_MAX_VIRTQUEUES and j == i,
dev->callfds[i] and dev->kickfds[i] are default 0.
So it will close(0), close the standard input (stdin).
And when the code fails in kickfd creation,
it will leaves one callfd not closed.

Fixes: e6e7ad8b3024 ("net/virtio-user: move eventfd open/close into init/uninit")
Cc: stable@dpdk.org:

Signed-off-by: Jiawei Zhu <zhujiawei12@huawei.com>
---
v2:
* Add close callfd when fail in kickfd creation before break.
---
---
 drivers/net/virtio/virtio_user/virtio_user_dev.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c
index 053f026..e1cbad0 100644
--- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
@@ -276,6 +276,7 @@ int virtio_user_stop_device(struct virtio_user_dev *dev)
 		}
 		kickfd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK);
 		if (kickfd < 0) {
+			close(callfd);
 			PMD_DRV_LOG(ERR, "kickfd error, %s", strerror(errno));
 			break;
 		}
@@ -284,7 +285,7 @@ int virtio_user_stop_device(struct virtio_user_dev *dev)
 	}
 
 	if (i < VIRTIO_MAX_VIRTQUEUES) {
-		for (j = 0; j <= i; ++j) {
+		for (j = 0; j < i; ++j) {
 			close(dev->callfds[j]);
 			close(dev->kickfds[j]);
 		}
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [dpdk-dev] [PATCH v2] net/virtio-user: fix run close(0) and close callfd
  2020-12-11 16:14 [dpdk-dev] [PATCH v2] net/virtio-user: fix run close(0) and close callfd Jiawei Zhu
                   ` (2 preceding siblings ...)
  2020-12-11 17:08 ` Jiawei Zhu
@ 2020-12-11 17:11 ` Jiawei Zhu
  2021-01-07 10:36   ` Maxime Coquelin
  2021-01-08  9:14   ` Maxime Coquelin
  3 siblings, 2 replies; 8+ messages in thread
From: Jiawei Zhu @ 2020-12-11 17:11 UTC (permalink / raw)
  To: dev

From: Jiawei Zhu <zhujiawei12@huawei.com>

When i < VIRTIO_MAX_VIRTQUEUES and j == i,
dev->callfds[i] and dev->kickfds[i] are default 0.
So it will close(0), close the standard input (stdin).
And when the code fails in kickfd creation,
it will leaves one callfd not closed.

Fixes: e6e7ad8b3024 ("net/virtio-user: move eventfd open/close into init/uninit")
Cc: stable@dpdk.org:

Signed-off-by: Jiawei Zhu <zhujiawei12@huawei.com>
---
v2:
* Add close callfd when fail in kickfd creation before break.
---
---
 drivers/net/virtio/virtio_user/virtio_user_dev.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c
index 053f026..e1cbad0 100644
--- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
@@ -276,6 +276,7 @@ int virtio_user_stop_device(struct virtio_user_dev *dev)
 		}
 		kickfd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK);
 		if (kickfd < 0) {
+			close(callfd);
 			PMD_DRV_LOG(ERR, "kickfd error, %s", strerror(errno));
 			break;
 		}
@@ -284,7 +285,7 @@ int virtio_user_stop_device(struct virtio_user_dev *dev)
 	}
 
 	if (i < VIRTIO_MAX_VIRTQUEUES) {
-		for (j = 0; j <= i; ++j) {
+		for (j = 0; j < i; ++j) {
 			close(dev->callfds[j]);
 			close(dev->kickfds[j]);
 		}
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [dpdk-dev] [PATCH v2] net/virtio-user: fix run close(0) and close callfd
  2020-12-11 16:53 ` Jiawei Zhu
@ 2020-12-14 13:02   ` Xia, Chenbo
  0 siblings, 0 replies; 8+ messages in thread
From: Xia, Chenbo @ 2020-12-14 13:02 UTC (permalink / raw)
  To: Jiawei Zhu, dev; +Cc: maxime.coquelin, stable

Hi Jiawei,

> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Jiawei Zhu
> Sent: Saturday, December 12, 2020 12:53 AM
> To: dev@dpdk.org
> Subject: [dpdk-dev] [PATCH v2] net/virtio-user: fix run close(0) and close
> callfd
> 
> From: Jiawei Zhu <zhujiawei12@huawei.com>
> 
> When i < VIRTIO_MAX_VIRTQUEUES and j == i,
> dev->callfds[i] and dev->kickfds[i] are default 0.
> So it will close(0), close the standard input (stdin).
> And when the code fails in kickfd creation,
> it will leaves one callfd not closed.
> 
> Fixes: e6e7ad8b3024 ("net/virtio-user: move eventfd open/close into
> init/uninit")
> Cc: stable@dpdk.org:
> 
> Signed-off-by: Jiawei Zhu <zhujiawei12@huawei.com>
> ---
> v2:
> * Add close callfd when fail in kickfd creation before break.
> ---
> ---
>  drivers/net/virtio/virtio_user/virtio_user_dev.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c
> b/drivers/net/virtio/virtio_user/virtio_user_dev.c
> index 053f026..e1cbad0 100644
> --- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
> +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
> @@ -276,6 +276,7 @@ int virtio_user_stop_device(struct virtio_user_dev
> *dev)
>  		}
>  		kickfd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK);
>  		if (kickfd < 0) {
> +			close(callfd);
>  			PMD_DRV_LOG(ERR, "kickfd error, %s", strerror(errno));
>  			break;
>  		}
> @@ -284,7 +285,7 @@ int virtio_user_stop_device(struct virtio_user_dev
> *dev)
>  	}
> 
>  	if (i < VIRTIO_MAX_VIRTQUEUES) {
> -		for (j = 0; j <= i; ++j) {
> +		for (j = 0; j < i; ++j) {
>  			close(dev->callfds[j]);
>  			close(dev->kickfds[j]);
>  		}
> --
> 1.8.3.1

Because you've sent duplicate ones, I will take this as the correct one.
Please don't send so many duplicate patches next time and don't send HTML 😊.
I'll help you clean up on patchwork, and thanks for your patch!

For this patch:

Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [dpdk-dev] [PATCH v2] net/virtio-user: fix run close(0) and close callfd
  2020-12-11 17:11 ` Jiawei Zhu
@ 2021-01-07 10:36   ` Maxime Coquelin
  2021-01-08  9:14   ` Maxime Coquelin
  1 sibling, 0 replies; 8+ messages in thread
From: Maxime Coquelin @ 2021-01-07 10:36 UTC (permalink / raw)
  To: Jiawei Zhu, dev; +Cc: stable

Cc'ing stable@dpdk.org.

On 12/11/20 6:11 PM, Jiawei Zhu wrote:
> From: Jiawei Zhu <zhujiawei12@huawei.com>
> 
> When i < VIRTIO_MAX_VIRTQUEUES and j == i,
> dev->callfds[i] and dev->kickfds[i] are default 0.
> So it will close(0), close the standard input (stdin).
> And when the code fails in kickfd creation,
> it will leaves one callfd not closed.
> 
> Fixes: e6e7ad8b3024 ("net/virtio-user: move eventfd open/close into init/uninit")
> Cc: stable@dpdk.org:
> 
> Signed-off-by: Jiawei Zhu <zhujiawei12@huawei.com>
> ---
> v2:
> * Add close callfd when fail in kickfd creation before break.
> ---
> ---
>  drivers/net/virtio/virtio_user/virtio_user_dev.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c
> index 053f026..e1cbad0 100644
> --- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
> +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
> @@ -276,6 +276,7 @@ int virtio_user_stop_device(struct virtio_user_dev *dev)
>  		}
>  		kickfd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK);
>  		if (kickfd < 0) {
> +			close(callfd);
>  			PMD_DRV_LOG(ERR, "kickfd error, %s", strerror(errno));
>  			break;
>  		}
> @@ -284,7 +285,7 @@ int virtio_user_stop_device(struct virtio_user_dev *dev)
>  	}
>  
>  	if (i < VIRTIO_MAX_VIRTQUEUES) {
> -		for (j = 0; j <= i; ++j) {
> +		for (j = 0; j < i; ++j) {
>  			close(dev->callfds[j]);
>  			close(dev->kickfds[j]);
>  		}
> 


Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>

Thanks!
Maxime


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [dpdk-dev] [PATCH v2] net/virtio-user: fix run close(0) and close callfd
  2020-12-11 17:11 ` Jiawei Zhu
  2021-01-07 10:36   ` Maxime Coquelin
@ 2021-01-08  9:14   ` Maxime Coquelin
  1 sibling, 0 replies; 8+ messages in thread
From: Maxime Coquelin @ 2021-01-08  9:14 UTC (permalink / raw)
  To: Jiawei Zhu, dev



On 12/11/20 6:11 PM, Jiawei Zhu wrote:
> From: Jiawei Zhu <zhujiawei12@huawei.com>
> 
> When i < VIRTIO_MAX_VIRTQUEUES and j == i,
> dev->callfds[i] and dev->kickfds[i] are default 0.
> So it will close(0), close the standard input (stdin).
> And when the code fails in kickfd creation,
> it will leaves one callfd not closed.
> 
> Fixes: e6e7ad8b3024 ("net/virtio-user: move eventfd open/close into init/uninit")
> Cc: stable@dpdk.org:
> 
> Signed-off-by: Jiawei Zhu <zhujiawei12@huawei.com>
> ---
> v2:
> * Add close callfd when fail in kickfd creation before break.
> ---
> ---
>  drivers/net/virtio/virtio_user/virtio_user_dev.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)


Series applied to dpdk-next-virtio/main.

Thanks,
Maxime


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-01-08  9:14 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-11 16:14 [dpdk-dev] [PATCH v2] net/virtio-user: fix run close(0) and close callfd Jiawei Zhu
2020-12-02 19:32 ` Jiawei Zhu
2020-12-11 16:53 ` Jiawei Zhu
2020-12-14 13:02   ` Xia, Chenbo
2020-12-11 17:08 ` Jiawei Zhu
2020-12-11 17:11 ` Jiawei Zhu
2021-01-07 10:36   ` Maxime Coquelin
2021-01-08  9:14   ` Maxime Coquelin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).