DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Xia, Chenbo" <chenbo.xia@intel.com>
To: David Marchand <david.marchand@redhat.com>,
	"dev@dpdk.org" <dev@dpdk.org>
Cc: "stable@dpdk.org" <stable@dpdk.org>,
	Maxime Coquelin <maxime.coquelin@redhat.com>,
	Hyong Youb Kim <hyonkim@cisco.com>,
	"Harman Kalra" <hkalra@marvell.com>
Subject: RE: [PATCH 2/3] net/vhost: fix leak in interrupt handle setup
Date: Fri, 10 Mar 2023 03:16:52 +0000	[thread overview]
Message-ID: <SN6PR11MB3504BB3AA3BF4034150050089CBA9@SN6PR11MB3504.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20230309123752.2237828-3-david.marchand@redhat.com>

> -----Original Message-----
> From: David Marchand <david.marchand@redhat.com>
> Sent: Thursday, March 9, 2023 8:38 PM
> To: dev@dpdk.org
> Cc: stable@dpdk.org; Maxime Coquelin <maxime.coquelin@redhat.com>; Xia,
> Chenbo <chenbo.xia@intel.com>; Hyong Youb Kim <hyonkim@cisco.com>; Harman
> Kalra <hkalra@marvell.com>
> Subject: [PATCH 2/3] net/vhost: fix leak in interrupt handle setup
> 
> Do a systematic cleanup if any part of the interrupt handle setup fails.
> 
> Fixes: d61138d4f0e2 ("drivers: remove direct access to interrupt handle")
> Cc: stable@dpdk.org
> 
> Signed-off-by: David Marchand <david.marchand@redhat.com>
> ---
>  drivers/net/vhost/rte_eth_vhost.c | 53 ++++++++++++++++++++-----------
>  1 file changed, 34 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/net/vhost/rte_eth_vhost.c
> b/drivers/net/vhost/rte_eth_vhost.c
> index 198bf4d1f4..96deb18d91 100644
> --- a/drivers/net/vhost/rte_eth_vhost.c
> +++ b/drivers/net/vhost/rte_eth_vhost.c
> @@ -686,25 +686,32 @@ eth_vhost_install_intr(struct rte_eth_dev *dev)
>  	dev->intr_handle =
> rte_intr_instance_alloc(RTE_INTR_INSTANCE_F_PRIVATE);
>  	if (dev->intr_handle == NULL) {
>  		VHOST_LOG(ERR, "Fail to allocate intr_handle\n");
> -		return -ENOMEM;
> +		ret = -ENOMEM;
> +		goto error;
> +	}
> +	if (rte_intr_efd_counter_size_set(dev->intr_handle,
> sizeof(uint64_t))) {
> +		ret = -rte_errno;
> +		goto error;
>  	}
> -	if (rte_intr_efd_counter_size_set(dev->intr_handle,
> sizeof(uint64_t)))
> -		return -rte_errno;
> 
>  	if (rte_intr_vec_list_alloc(dev->intr_handle, NULL, nb_rxq)) {
> -		VHOST_LOG(ERR,
> -			"Failed to allocate memory for interrupt vector\n");
> -		rte_intr_instance_free(dev->intr_handle);
> -		return -ENOMEM;
> +		VHOST_LOG(ERR, "Failed to allocate memory for interrupt
> vector\n");
> +		ret = -ENOMEM;
> +		goto error;
>  	}
> 
> 
>  	VHOST_LOG(INFO, "Prepare intr vec\n");
>  	for (i = 0; i < nb_rxq; i++) {
> -		if (rte_intr_vec_list_index_set(dev->intr_handle, i,
> RTE_INTR_VEC_RXTX_OFFSET + i))
> -			return -rte_errno;
> -		if (rte_intr_efds_index_set(dev->intr_handle, i, -1))
> -			return -rte_errno;
> +		if (rte_intr_vec_list_index_set(dev->intr_handle, i,
> +				RTE_INTR_VEC_RXTX_OFFSET + i)) {
> +			ret = -rte_errno;
> +			goto error;
> +		}
> +		if (rte_intr_efds_index_set(dev->intr_handle, i, -1)) {
> +			ret = -rte_errno;
> +			goto error;
> +		}
>  		vq = dev->data->rx_queues[i];
>  		if (!vq) {
>  			VHOST_LOG(INFO, "rxq-%d not setup yet, skip!\n", i);
> @@ -729,16 +736,24 @@ eth_vhost_install_intr(struct rte_eth_dev *dev)
>  		VHOST_LOG(INFO, "Installed intr vec for rxq-%d\n", i);
>  	}
> 
> -	if (rte_intr_nb_efd_set(dev->intr_handle, nb_rxq))
> -		return -rte_errno;
> -
> -	if (rte_intr_max_intr_set(dev->intr_handle, nb_rxq + 1))
> -		return -rte_errno;
> -
> -	if (rte_intr_type_set(dev->intr_handle, RTE_INTR_HANDLE_VDEV))
> -		return -rte_errno;
> +	if (rte_intr_nb_efd_set(dev->intr_handle, nb_rxq)) {
> +		ret = -rte_errno;
> +		goto error;
> +	}
> +	if (rte_intr_max_intr_set(dev->intr_handle, nb_rxq + 1)) {
> +		ret = -rte_errno;
> +		goto error;
> +	}
> +	if (rte_intr_type_set(dev->intr_handle, RTE_INTR_HANDLE_VDEV)) {
> +		ret = -rte_errno;
> +		goto error;
> +	}
> 
>  	return 0;
> +
> +error:
> +	eth_vhost_uninstall_intr(dev);
> +	return ret;
>  }
> 
>  static void
> --
> 2.39.2

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

  reply	other threads:[~2023-03-10  3:17 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-09 12:37 [PATCH 0/3] net/vhost pmd fixes for Rx interrupts David Marchand
2023-03-09 12:37 ` [PATCH 1/3] net/vhost: add missing newline in logs David Marchand
2023-03-10  3:16   ` Xia, Chenbo
2023-03-09 12:37 ` [PATCH 2/3] net/vhost: fix leak in interrupt handle setup David Marchand
2023-03-10  3:16   ` Xia, Chenbo [this message]
2023-03-09 12:37 ` [PATCH 3/3] net/vhost: fix Rx interrupt David Marchand
2023-03-10  7:35   ` Xia, Chenbo
2023-03-13  2:39   ` Yuan, DukaiX
2023-03-14  8:59   ` David Marchand
2023-03-14 11:07     ` Maxime Coquelin
2023-03-16 14:47 ` [PATCH 0/3] net/vhost pmd fixes for Rx interrupts Maxime Coquelin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=SN6PR11MB3504BB3AA3BF4034150050089CBA9@SN6PR11MB3504.namprd11.prod.outlook.com \
    --to=chenbo.xia@intel.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=hkalra@marvell.com \
    --cc=hyonkim@cisco.com \
    --cc=maxime.coquelin@redhat.com \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).