summaryrefslogtreecommitdiff
path: root/examples/vhost_scsi
diff options
context:
space:
mode:
authorBruce Richardson <bruce.richardson@intel.com>2019-04-08 10:46:37 +0100
committerThomas Monjalon <thomas@monjalon.net>2019-04-23 00:15:10 +0200
commit6fd5b5734faf2f902aebf57e966e5adb0499a1ff (patch)
tree920a2e79252dad270f29f5520dfda45df2cfbaf8 /examples/vhost_scsi
parentf38020697976ad9b6baef5d45e393ed1db827083 (diff)
downloaddpdk-6fd5b5734faf2f902aebf57e966e5adb0499a1ff.zip
dpdk-6fd5b5734faf2f902aebf57e966e5adb0499a1ff.tar.gz
dpdk-6fd5b5734faf2f902aebf57e966e5adb0499a1ff.tar.xz
examples/vhost_scsi: fix null-check for parameter
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 Signed-off-by: Bruce Richardson <bruce.richardson@intel.com> Reviewed-by: Tiwei Bie <tiwei.bie@intel.com>
Diffstat (limited to 'examples/vhost_scsi')
-rw-r--r--examples/vhost_scsi/vhost_scsi.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/examples/vhost_scsi/vhost_scsi.c b/examples/vhost_scsi/vhost_scsi.c
index 2908ff6..513af0c 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(stderr, "%s: Error, invalid argument passed to worker thread\n",
+ __func__);
+ exit(0);
+ }
+
thread = pthread_self();
CPU_ZERO(&cpuset);
CPU_SET(0, &cpuset);