raw/ioat: fix dereference before null check
PATCH 1/1 raw/ioat: fix dereference before null check
The 'idxd' pointer in 'idxd_rawdev_destroy()' is being dereferenced before it is checked. To fix this, the null pointer check was moved to occur earlier in the code.
Coverity issue: 363040
Fixes ff06fa2cf3ba ("raw/ioat: probe idxd PCI")
Signed-off-by Kevin Laatz <[email protected]>
--- drivers/raw/ioat/idxd_pci.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
drivers/raw/ioat/idxd_pci.c +9 -7
@@ -290,6 +290,10 @@ idxd_rawdev_destroy(const char *name) } idxd = rdev->dev_private; +if (!idxd) { +IOAT_PMD_ERR ("Error getting dev_private" ); +return -EINVAL ; + }/* disable the device */ err_code =idxd_pci_dev_command (idxd, idxd_disable_dev);
@@ -300,13 +304,11 @@ idxd_rawdev_destroy(const char *name)IOAT_PMD_DEBUG ("IDXD Device disabled OK" );/* free device memory */ -if (rdev->dev_private !=NULL ) { -IOAT_PMD_DEBUG ("Freeing device driver memory" ); - rdev->dev_private =NULL ; -rte_free (idxd->public.batch_ring); -rte_free (idxd->public.hdl_ring); -rte_memzone_free (idxd->mz); - } +IOAT_PMD_DEBUG ("Freeing device driver memory" ); + rdev->dev_private =NULL ; +rte_free (idxd->public.batch_ring); +rte_free (idxd->public.hdl_ring); +rte_memzone_free (idxd->mz);/* rte_rawdev_close is called by pmd_release */ ret =rte_rawdev_pmd_release (rdev);
Signature · 1 line
2.25.1
Quoted 9 lines · Kevin Laatz
The 'idxd' pointer in '
idxd_rawdev_destroy()' is being dereferenced before it is checked. To fix this, the null pointer check was moved to occur earlier in the code.Coverity issue: 363040
Fixes ff06fa2cf3ba ("raw/ioat: probe idxd PCI")Signed-off-by Kevin Laatz <[email protected]>---
Acked-by Bruce Richardson <[email protected]>
Thomas Monjalon
Applied14/10/2020 13:34, Bruce Richardson:
Quoted 11 lines · Kevin Laatz
Quoted 9 lines
The 'idxd' pointer in '
idxd_rawdev_destroy()' is being dereferenced before it is checked. To fix this, the null pointer check was moved to occur earlier in the code.Coverity issue: 363040
Fixes ff06fa2cf3ba ("raw/ioat: probe idxd PCI")Signed-off-by Kevin Laatz <[email protected]>---
Acked-by Bruce Richardson <[email protected]>
Applied, thanks