The service proxy is initialized at 0. This is assuming that all of its fields are invalid at 0. The issue is that a file descriptor at 0 is a valid one.
The value -1 is used as sentinel during cleanup. Initialize the RX proxy file descriptor to -1. Fixes: 366226dd859f ("net/failsafe: fix fd leak") Signed-off-by: Gaetan Rivet <gr...@u256.net> Cc: wangyunj...@huawei.com Cc: Ali Alnubani <alia...@mellanox.com> --- drivers/net/failsafe/failsafe.c | 1 + drivers/net/failsafe/failsafe_private.h | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/drivers/net/failsafe/failsafe.c b/drivers/net/failsafe/failsafe.c index 8af31d71b..72362f35d 100644 --- a/drivers/net/failsafe/failsafe.c +++ b/drivers/net/failsafe/failsafe.c @@ -190,6 +190,7 @@ fs_eth_dev_create(struct rte_vdev_device *vdev) } priv = PRIV(dev); priv->data = dev->data; + priv->rxp = FS_RX_PROXY_INIT; dev->dev_ops = &failsafe_ops; dev->data->mac_addrs = &PRIV(dev)->mac_addrs[0]; dev->data->dev_link = eth_link; diff --git a/drivers/net/failsafe/failsafe_private.h b/drivers/net/failsafe/failsafe_private.h index 8e9706aef..651578a12 100644 --- a/drivers/net/failsafe/failsafe_private.h +++ b/drivers/net/failsafe/failsafe_private.h @@ -58,6 +58,14 @@ struct rx_proxy { enum rxp_service_state sstate; }; +#define FS_RX_PROXY_INIT (struct rx_proxy){ \ + .efd = -1, \ + .evec = NULL, \ + .sid = 0, \ + .scid = 0, \ + .sstate = SS_NO_SERVICE, \ +} + struct rxq { struct fs_priv *priv; uint16_t qid; -- 2.26.2