examples/vhost_scsi: fix null-check for parameter
authorBruce Richardson <bruce.richardson@intel.com>
Mon, 8 Apr 2019 09:46:37 +0000 (10:46 +0100)
committerThomas Monjalon <thomas@monjalon.net>
Mon, 22 Apr 2019 22:15:10 +0000 (00:15 +0200)
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>
examples/vhost_scsi/vhost_scsi.c

index 2908ff68b71c43c74e8adc96fb9925f13e6751b9..513af0cca4bc62964e6955ca99c44975916d8d9a 100644 (file)
@@ -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);