From: Wei Huang Date: Thu, 5 Nov 2020 02:05:40 +0000 (-0500) Subject: raw/ifpga/base: check adapter pointer before dereference X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=e6dc14c8008c1e559bd75a5c9eba4b39e0e07d33;p=dpdk.git raw/ifpga/base: check adapter pointer before dereference In opae_adapter_destroy(), pointer "adapter" is not validated before passing it to opae_adapter_shm_free() and opae_adapter_mutex_close() which dereference it. Coverity issue: 363752 Fixes: e41856b515ce ("raw/ifpga/base: enhance driver reliability in multi-process") Signed-off-by: Wei Huang Acked-by: Rosen Xu --- diff --git a/drivers/raw/ifpga/base/opae_hw_api.c b/drivers/raw/ifpga/base/opae_hw_api.c index 600afdea1c..d5cd5fe608 100644 --- a/drivers/raw/ifpga/base/opae_hw_api.c +++ b/drivers/raw/ifpga/base/opae_hw_api.c @@ -605,10 +605,12 @@ int opae_adapter_enumerate(struct opae_adapter *adapter) */ void opae_adapter_destroy(struct opae_adapter *adapter) { - if (adapter && adapter->ops && adapter->ops->destroy) - adapter->ops->destroy(adapter); - opae_adapter_shm_free(adapter); - opae_adapter_mutex_close(adapter); + if (adapter) { + if (adapter->ops && adapter->ops->destroy) + adapter->ops->destroy(adapter); + opae_adapter_shm_free(adapter); + opae_adapter_mutex_close(adapter); + } } /**