patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Harman Kalra <hkalra@marvell.com>
To: wangyunjian <wangyunjian@huawei.com>
Cc: <dev@dpdk.org>, <ferruh.yigit@intel.com>,
	<david.marchand@redhat.com>, <jerinj@marvell.com>,
	<jerry.lilijun@huawei.com>, <xudingke@huawei.com>,
	<stable@dpdk.org>
Subject: Re: [dpdk-stable] [EXT] [dpdk-dev] [PATCH v2] eal: fix dereference after null check
Date: Thu, 29 Oct 2020 02:48:46 +0530
Message-ID: <20201028211845.GB137989@outlook.office365.com> (raw)
In-Reply-To: <1602751350-2808-1-git-send-email-wangyunjian@huawei.com>

On Thu, Oct 15, 2020 at 04:42:30PM +0800, wangyunjian wrote:
> External Email
> 
> ----------------------------------------------------------------------
> From: Yunjian Wang <wangyunjian@huawei.com>
> 
> This patch fixes (dereference after null check) coverity issue.
> For this reason, we should add null check at the beginning of the
> function and return error directly if the 'intr_handle' is null.
> 
> Coverity issue: 357695, 357751
> Fixes: 05c4105738d8 ("trace: add interrupt tracepoints")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>

Thanks for fixing this.

Reviewed-by: Harman Kalra <hkalra@marvell.com>

> ---
> v2:
>   fix code styles suggested by Ferruh Yigit
> ---
>  lib/librte_eal/freebsd/eal_interrupts.c | 16 ++++++++++------
>  lib/librte_eal/linux/eal_interrupts.c   | 16 ++++++++++------
>  2 files changed, 20 insertions(+), 12 deletions(-)
> 
> diff --git a/lib/librte_eal/freebsd/eal_interrupts.c b/lib/librte_eal/freebsd/eal_interrupts.c
> index 6d53d33c8..211fd4f8d 100644
> --- a/lib/librte_eal/freebsd/eal_interrupts.c
> +++ b/lib/librte_eal/freebsd/eal_interrupts.c
> @@ -350,13 +350,15 @@ rte_intr_enable(const struct rte_intr_handle *intr_handle)
>  {
>  	int rc = 0;
>  
> -	if (intr_handle && intr_handle->type == RTE_INTR_HANDLE_VDEV) {
> +	if (intr_handle == NULL)
> +		return -1;
> +
> +	if (intr_handle->type == RTE_INTR_HANDLE_VDEV) {
>  		rc = 0;
>  		goto out;
>  	}
>  
> -	if (!intr_handle || intr_handle->fd < 0 ||
> -				intr_handle->uio_cfg_fd < 0) {
> +	if (intr_handle->fd < 0 || intr_handle->uio_cfg_fd < 0) {
>  		rc = -1;
>  		goto out;
>  	}
> @@ -389,13 +391,15 @@ rte_intr_disable(const struct rte_intr_handle *intr_handle)
>  {
>  	int rc = 0;
>  
> -	if (intr_handle && intr_handle->type == RTE_INTR_HANDLE_VDEV) {
> +	if (intr_handle == NULL)
> +		return -1;
> +
> +	if (intr_handle->type == RTE_INTR_HANDLE_VDEV) {
>  		rc = 0;
>  		goto out;
>  	}
>  
> -	if (!intr_handle || intr_handle->fd < 0 ||
> -				intr_handle->uio_cfg_fd < 0) {
> +	if (intr_handle->fd < 0 || intr_handle->uio_cfg_fd < 0) {
>  		rc = -1;
>  		goto out;
>  	}
> diff --git a/lib/librte_eal/linux/eal_interrupts.c b/lib/librte_eal/linux/eal_interrupts.c
> index 13db5c4e8..f1bd0356c 100644
> --- a/lib/librte_eal/linux/eal_interrupts.c
> +++ b/lib/librte_eal/linux/eal_interrupts.c
> @@ -667,13 +667,15 @@ rte_intr_enable(const struct rte_intr_handle *intr_handle)
>  {
>  	int rc = 0;
>  
> -	if (intr_handle && intr_handle->type == RTE_INTR_HANDLE_VDEV) {
> +	if (intr_handle == NULL)
> +		return -1;
> +
> +	if (intr_handle->type == RTE_INTR_HANDLE_VDEV) {
>  		rc = 0;
>  		goto out;
>  	}
>  
> -	if (!intr_handle || intr_handle->fd < 0 ||
> -			intr_handle->uio_cfg_fd < 0) {
> +	if (intr_handle->fd < 0 || intr_handle->uio_cfg_fd < 0) {
>  		rc = -1;
>  		goto out;
>  	}
> @@ -794,13 +796,15 @@ rte_intr_disable(const struct rte_intr_handle *intr_handle)
>  {
>  	int rc = 0;
>  
> -	if (intr_handle && intr_handle->type == RTE_INTR_HANDLE_VDEV) {
> +	if (intr_handle == NULL)
> +		return -1;
> +
> +	if (intr_handle->type == RTE_INTR_HANDLE_VDEV) {
>  		rc = 0;
>  		goto out;
>  	}
>  
> -	if (!intr_handle || intr_handle->fd < 0 ||
> -					intr_handle->uio_cfg_fd < 0) {
> +	if (intr_handle->fd < 0 || intr_handle->uio_cfg_fd < 0) {
>  		rc = -1;
>  		goto out;
>  	}
> -- 
> 2.23.0
> 

  parent reply	other threads:[~2020-10-28 21:19 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-19 10:34 [dpdk-stable] [dpdk-dev] [PATCH] eal: fix dereference before " wangyunjian
2020-10-14 17:02 ` Ferruh Yigit
2020-10-15  2:29   ` wangyunjian
2020-10-15  8:42 ` [dpdk-stable] [dpdk-dev] [PATCH v2] eal: fix dereference after " wangyunjian
2020-10-22 20:01   ` David Marchand
2020-10-28 21:18   ` Harman Kalra [this message]
2020-10-29 16:09     ` [dpdk-stable] [EXT] " David Marchand

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=20201028211845.GB137989@outlook.office365.com \
    --to=hkalra@marvell.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=jerinj@marvell.com \
    --cc=jerry.lilijun@huawei.com \
    --cc=stable@dpdk.org \
    --cc=wangyunjian@huawei.com \
    --cc=xudingke@huawei.com \
    /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

patches for DPDK stable branches

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/stable/0 stable/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 stable stable/ https://inbox.dpdk.org/stable \
		stable@dpdk.org
	public-inbox-index stable

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.stable


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git