DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Li, Xiaoyun" <xiaoyun.li@intel.com>
To: "Min Hu (Connor)" <humin29@huawei.com>, "dev@dpdk.org" <dev@dpdk.org>
Cc: "Yigit, Ferruh" <ferruh.yigit@intel.com>,
	"Wu, Jingjing" <jingjing.wu@intel.com>
Subject: Re: [dpdk-dev] [PATCH 1/2] raw/ntb: check spad user index
Date: Wed, 21 Apr 2021 03:31:14 +0000	[thread overview]
Message-ID: <CH0PR11MB5523310F2068D852009E3A7299479@CH0PR11MB5523.namprd11.prod.outlook.com> (raw)
In-Reply-To: <1618970896-37852-2-git-send-email-humin29@huawei.com>

Hi

> -----Original Message-----
> From: Min Hu (Connor) <humin29@huawei.com>
> Sent: Wednesday, April 21, 2021 10:08
> To: dev@dpdk.org
> Cc: Yigit, Ferruh <ferruh.yigit@intel.com>; Li, Xiaoyun <xiaoyun.li@intel.com>;
> Wu, Jingjing <jingjing.wu@intel.com>
> Subject: [PATCH 1/2] raw/ntb: check spad user index
> 
> From: Chengwen Feng <fengchengwen@huawei.com>
> 
> This patch adds checking spad user index validity when set or get attr.
> 
> Fixes: 277310027965 ("raw/ntb: introduce NTB raw device driver")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
> Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
> ---
>  drivers/raw/ntb/ntb.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/drivers/raw/ntb/ntb.c b/drivers/raw/ntb/ntb.c index
> 6dd213e..0f0e3f2 100644
> --- a/drivers/raw/ntb/ntb.c
> +++ b/drivers/raw/ntb/ntb.c
> @@ -1080,6 +1080,10 @@ ntb_attr_set(struct rte_rawdev *dev, const char
> *attr_name,
>  		if (hw->ntb_ops->spad_write == NULL)
>  			return -ENOTSUP;
>  		index = atoi(&attr_name[NTB_SPAD_USER_LEN]);
> +		if (index < 0 || index >= NTB_SPAD_USER_MAX_NUM) {
> +			NTB_LOG(ERR, "Invalid attribute (%s)", attr_name);
> +			return -EINVAL;
> +		}

It's unnecessary. The value will be checked in intel_ntb_spad_write(). There will be error remind in that.

>  		(*hw->ntb_ops->spad_write)(dev, hw->spad_user_list[index],
>  					   1, attr_value);
>  		NTB_LOG(DEBUG, "Set attribute (%s) Value (%" PRIu64 ")", @@
> -1174,6 +1178,10 @@ ntb_attr_get(struct rte_rawdev *dev, const char
> *attr_name,
>  		if (hw->ntb_ops->spad_read == NULL)
>  			return -ENOTSUP;
>  		index = atoi(&attr_name[NTB_SPAD_USER_LEN]);
> +		if (index < 0 || index >= NTB_SPAD_USER_MAX_NUM) {
> +			NTB_LOG(ERR, "Attribute (%s) out of range",
> attr_name);
> +			return -EINVAL;
> +		}

Same as above.

>  		*attr_value = (*hw->ntb_ops->spad_read)(dev,
>  				hw->spad_user_list[index], 0);
>  		NTB_LOG(DEBUG, "Attribute (%s) Value (%" PRIu64 ")",
> --
> 2.7.4


  reply	other threads:[~2021-04-21  3:31 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-21  2:08 [dpdk-dev] [PATCH 0/2] bugfix for raw ntb Min Hu (Connor)
2021-04-21  2:08 ` [dpdk-dev] [PATCH 1/2] raw/ntb: check spad user index Min Hu (Connor)
2021-04-21  3:31   ` Li, Xiaoyun [this message]
2021-04-21  3:54     ` fengchengwen
2021-04-21  4:36     ` Min Hu (Connor)
2021-04-21  4:54       ` Li, Xiaoyun
2021-04-21  6:08         ` Min Hu (Connor)
2021-05-05 20:37           ` Thomas Monjalon
2021-04-22  5:05   ` Li, Xiaoyun
2021-05-05 21:04     ` Thomas Monjalon
2021-04-21  2:08 ` [dpdk-dev] [PATCH 2/2] raw/ntb: check malloc result Min Hu (Connor)
2021-04-21  3:33   ` Li, Xiaoyun

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=CH0PR11MB5523310F2068D852009E3A7299479@CH0PR11MB5523.namprd11.prod.outlook.com \
    --to=xiaoyun.li@intel.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=humin29@huawei.com \
    --cc=jingjing.wu@intel.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
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).