From: Tiwei Bie <tiwei.bie@intel.com>
To: Bruce Richardson <bruce.richardson@intel.com>
Cc: dev@dpdk.org, stable@dpdk.org,
Maxime Coquelin <maxime.coquelin@redhat.com>,
Zhihong Wang <zhihong.wang@intel.com>
Subject: Re: [dpdk-dev] [PATCH v2 2/5] examples/vhost_scsi: fix missing NULL-check for parameter
Date: Mon, 8 Apr 2019 11:31:11 +0800 [thread overview]
Message-ID: <20190408033110.GB20719@dpdk-tbie.sh.intel.com> (raw)
Message-ID: <20190408033111.4tW4Fg0En_ndBKwbH-BeUSpoJ-9LCpg-ZA8i2v-yNlU@z> (raw)
In-Reply-To: <20190405143709.50352-3-bruce.richardson@intel.com>
On Fri, Apr 05, 2019 at 03:37:06PM +0100, Bruce Richardson wrote:
> Coverity points out that there is a check in the main thread loop for the
> ctrlr->bdev being NULL, but by that stage the pointer has already been
> dereferenced. Therefore, for safety, before we enter the loop do an
> initial check on the parameter structure.
>
> Coverity issue: 158657
> Fixes: db75c7af19bb ("examples/vhost_scsi: introduce a new sample app")
> CC: stable@dpdk.org
> CC: Maxime Coquelin <maxime.coquelin@redhat.com>
> CC: Tiwei Bie <tiwei.bie@intel.com>
> CC: Zhihong Wang <zhihong.wang@intel.com>
>
> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> ---
> examples/vhost_scsi/vhost_scsi.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/examples/vhost_scsi/vhost_scsi.c b/examples/vhost_scsi/vhost_scsi.c
> index 2908ff68b..a6465d089 100644
> --- a/examples/vhost_scsi/vhost_scsi.c
> +++ b/examples/vhost_scsi/vhost_scsi.c
> @@ -285,6 +285,12 @@ ctrlr_worker(void *arg)
> cpu_set_t cpuset;
> pthread_t thread;
>
> + if (ctrlr == NULL || ctrlr->bdev == NULL) {
> + fprintf(stdout, "%s: Error, invalid argument passed to worker thread\n",
Might be better to print to stderr.
> + __func__);
> + return NULL;
Might be better to exit() directly like what the other
error handling in this thread does:
https://github.com/DPDK/dpdk/blob/bdcfcceb7a0b7534a0dba669279d18bd0f98d5e5/examples/vhost_scsi/vhost_scsi.c#L296-L299
Otherwise destroy_device() will hang on sem_wait(&exit_sem):
https://github.com/DPDK/dpdk/blob/bdcfcceb7a0b7534a0dba669279d18bd0f98d5e5/examples/vhost_scsi/vhost_scsi.c#L390
Thanks,
Tiwei
> + }
> +
> thread = pthread_self();
> CPU_ZERO(&cpuset);
> CPU_SET(0, &cpuset);
> --
> 2.20.1
>
next prev parent reply other threads:[~2019-04-08 3:31 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-05 13:45 [dpdk-dev] [PATCH 0/5] some small fixes Bruce Richardson
2019-04-05 13:45 ` Bruce Richardson
2019-04-05 13:45 ` [dpdk-dev] [PATCH 1/5] examples/vhost_scsi: fix header check for meson build Bruce Richardson
2019-04-05 13:45 ` Bruce Richardson
2019-04-05 13:45 ` [dpdk-dev] [PATCH 2/5] examples/vhost_scsi: fix missing NULL-check for parameter Bruce Richardson
2019-04-05 13:45 ` Bruce Richardson
2019-04-05 13:45 ` [dpdk-dev] [PATCH 3/5] net/i40e: fix dereference before NULL check in mbuf release Bruce Richardson
2019-04-05 13:45 ` Bruce Richardson
2019-04-05 14:08 ` Rami Rosen
2019-04-05 14:08 ` Rami Rosen
2019-04-05 13:45 ` [dpdk-dev] [PATCH 4/5] app/testpmd: fix variable use before NULL check Bruce Richardson
2019-04-05 13:45 ` Bruce Richardson
2019-04-05 14:13 ` Rami Rosen
2019-04-05 14:13 ` Rami Rosen
2019-04-05 13:45 ` [dpdk-dev] [PATCH 5/5] net/i40e: fix dereference before check when getting EEPROM Bruce Richardson
2019-04-05 13:45 ` Bruce Richardson
2019-04-05 14:19 ` Rami Rosen
2019-04-05 14:19 ` Rami Rosen
2019-04-05 14:37 ` [dpdk-dev] [PATCH v2 0/5] some small fixes Bruce Richardson
2019-04-05 14:37 ` Bruce Richardson
2019-04-05 14:37 ` [dpdk-dev] [PATCH v2 1/5] examples/vhost_scsi: fix header check for meson build Bruce Richardson
2019-04-05 14:37 ` Bruce Richardson
2019-04-08 3:23 ` Tiwei Bie
2019-04-08 3:23 ` Tiwei Bie
2019-04-05 14:37 ` [dpdk-dev] [PATCH v2 2/5] examples/vhost_scsi: fix missing NULL-check for parameter Bruce Richardson
2019-04-05 14:37 ` Bruce Richardson
2019-04-08 3:31 ` Tiwei Bie [this message]
2019-04-08 3:31 ` Tiwei Bie
2019-04-08 9:37 ` Bruce Richardson
2019-04-08 9:37 ` Bruce Richardson
2019-04-05 14:37 ` [dpdk-dev] [PATCH v2 3/5] net/i40e: fix dereference before NULL check in mbuf release Bruce Richardson
2019-04-05 14:37 ` Bruce Richardson
2019-04-05 14:37 ` [dpdk-dev] [PATCH v2 4/5] app/testpmd: fix variable use before NULL check Bruce Richardson
2019-04-05 14:37 ` Bruce Richardson
2019-04-05 14:37 ` [dpdk-dev] [PATCH v2 5/5] net/i40e: fix dereference before check when getting EEPROM Bruce Richardson
2019-04-05 14:37 ` Bruce Richardson
2019-04-08 9:46 ` [dpdk-dev] [PATCH v3 0/5] some small fixes Bruce Richardson
2019-04-08 9:46 ` Bruce Richardson
2019-04-08 9:46 ` [dpdk-dev] [PATCH v3 1/5] examples/vhost_scsi: fix header check for meson build Bruce Richardson
2019-04-08 9:46 ` Bruce Richardson
2019-04-08 9:46 ` [dpdk-dev] [PATCH v3 2/5] examples/vhost_scsi: fix missing NULL-check for parameter Bruce Richardson
2019-04-08 9:46 ` Bruce Richardson
2019-04-09 1:53 ` Tiwei Bie
2019-04-09 1:53 ` Tiwei Bie
2019-04-08 9:46 ` [dpdk-dev] [PATCH v3 3/5] net/i40e: fix dereference before NULL check in mbuf release Bruce Richardson
2019-04-08 9:46 ` Bruce Richardson
2019-04-08 9:46 ` [dpdk-dev] [PATCH v3 4/5] app/testpmd: fix variable use before NULL check Bruce Richardson
2019-04-08 9:46 ` Bruce Richardson
2019-04-08 9:46 ` [dpdk-dev] [PATCH v3 5/5] net/i40e: fix dereference before check when getting EEPROM Bruce Richardson
2019-04-08 9:46 ` Bruce Richardson
2019-04-22 21:49 ` [dpdk-dev] [PATCH v3 0/5] some small fixes Thomas Monjalon
2019-04-22 21:49 ` Thomas Monjalon
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=20190408033110.GB20719@dpdk-tbie.sh.intel.com \
--to=tiwei.bie@intel.com \
--cc=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
--cc=maxime.coquelin@redhat.com \
--cc=stable@dpdk.org \
--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).