patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Ye Xiaolong <xiaolong.ye@intel.com>
To: Tiwei Bie <tiwei.bie@intel.com>
Cc: Mohammad Abdul Awal <mohammad.abdul.awal@intel.com>,
	dev@dpdk.org, maxime.coquelin@redhat.com, zhihong.wang@intel.com,
	stable@dpdk.org
Subject: Re: [dpdk-stable] [dpdk-dev] [PATCH 3/3] vhost: fix null pointer checking
Date: Thu, 4 Apr 2019 14:47:24 +0800	[thread overview]
Message-ID: <20190404064724.GA33544@intel.com> (raw)
In-Reply-To: <20190404060354.GA5423@dpdk-tbie.sh.intel.com>

Hi, Tiwei,

On 04/04, Tiwei Bie wrote:
[snip]
>> @@ -515,7 +515,7 @@ rte_vhost_get_ifname(int vid, char *buf, size_t len)
>>  {
>>  	struct virtio_net *dev = get_device(vid);
>>  
>> -	if (dev == NULL)
>> +	if (dev == NULL || !buf)
>
>It would be better to do the check in this way: (!dev || !buf)
>for consistency.
>

According to DPDK coding conventions 1.8.1 on NULL pointers [1], shouldn't it be

if (dev == NULL || buf == NULL)?

[1] https://doc.dpdk.org/guides/contributing/coding_style.html#null-pointers

Thanks,
Xiaolong
>Thanks for the work!
>Tiwei
>
>
>>  		return -1;
>>  
>>  	len = RTE_MIN(len, sizeof(dev->ifname));
>> @@ -532,7 +532,7 @@ rte_vhost_get_negotiated_features(int vid, uint64_t *features)
>>  	struct virtio_net *dev;
>>  
>>  	dev = get_device(vid);
>> -	if (!dev)
>> +	if (!dev || !features)
>>  		return -1;
>>  
>>  	*features = dev->features;
>> @@ -547,7 +547,7 @@ rte_vhost_get_mem_table(int vid, struct rte_vhost_memory **mem)
>>  	size_t size;
>>  
>>  	dev = get_device(vid);
>> -	if (!dev)
>> +	if (!dev || !mem)
>>  		return -1;
>>  
>>  	size = dev->mem->nregions * sizeof(struct rte_vhost_mem_region);
>> @@ -570,7 +570,7 @@ rte_vhost_get_vhost_vring(int vid, uint16_t vring_idx,
>>  	struct vhost_virtqueue *vq;
>>  
>>  	dev = get_device(vid);
>> -	if (!dev)
>> +	if (!dev || !vring)
>>  		return -1;
>>  
>>  	if (vring_idx >= VHOST_MAX_VRING)
>> @@ -763,7 +763,7 @@ int rte_vhost_get_log_base(int vid, uint64_t *log_base,
>>  {
>>  	struct virtio_net *dev = get_device(vid);
>>  
>> -	if (!dev)
>> +	if (!dev || !log_base || !log_size)
>>  		return -1;
>>  
>>  	*log_base = dev->log_base;
>> @@ -777,7 +777,7 @@ int rte_vhost_get_vring_base(int vid, uint16_t queue_id,
>>  {
>>  	struct virtio_net *dev = get_device(vid);
>>  
>> -	if (!dev)
>> +	if (!dev || !last_avail_idx || !last_used_idx)
>>  		return -1;
>>  
>>  	*last_avail_idx = dev->virtqueue[queue_id]->last_avail_idx;
>> @@ -805,7 +805,7 @@ int rte_vhost_extern_callback_register(int vid,
>>  {
>>  	struct virtio_net *dev = get_device(vid);
>>  
>> -	if (!dev)
>> +	if (!dev || !ops)
>>  		return -1;
>>  
>>  	dev->extern_ops = *ops;
>> -- 
>> 2.17.1
>> 

  reply	other threads:[~2019-04-04  6:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-03 16:08 [dpdk-stable] " Mohammad Abdul Awal
2019-04-04  6:03 ` Tiwei Bie
2019-04-04  6:47   ` Ye Xiaolong [this message]
2019-04-04  7:01     ` [dpdk-stable] [dpdk-dev] " Tiwei Bie

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=20190404064724.GA33544@intel.com \
    --to=xiaolong.ye@intel.com \
    --cc=dev@dpdk.org \
    --cc=maxime.coquelin@redhat.com \
    --cc=mohammad.abdul.awal@intel.com \
    --cc=stable@dpdk.org \
    --cc=tiwei.bie@intel.com \
    --cc=zhihong.wang@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).