DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] raw/ioat: fix dereference before null check
@ 2020-10-14 10:11 Kevin Laatz
  2020-10-14 11:34 ` Bruce Richardson
  0 siblings, 1 reply; 3+ messages in thread
From: Kevin Laatz @ 2020-10-14 10:11 UTC (permalink / raw)
  To: dev; +Cc: bruce.richardson, 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 <kevin.laatz@intel.com>
---
 drivers/raw/ioat/idxd_pci.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/raw/ioat/idxd_pci.c b/drivers/raw/ioat/idxd_pci.c
index 165a9ea7f1..d4d87b199d 100644
--- a/drivers/raw/ioat/idxd_pci.c
+++ b/drivers/raw/ioat/idxd_pci.c
@@ -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);
-- 
2.25.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-dev] [PATCH] raw/ioat: fix dereference before null check
  2020-10-14 10:11 [dpdk-dev] [PATCH] raw/ioat: fix dereference before null check Kevin Laatz
@ 2020-10-14 11:34 ` Bruce Richardson
  2020-10-19  8:24   ` Thomas Monjalon
  0 siblings, 1 reply; 3+ messages in thread
From: Bruce Richardson @ 2020-10-14 11:34 UTC (permalink / raw)
  To: Kevin Laatz; +Cc: dev

On Wed, Oct 14, 2020 at 11:11:10AM +0100, Kevin Laatz wrote:
> 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 <kevin.laatz@intel.com>
> ---
Acked-by: Bruce Richardson <bruce.richardson@intel.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-dev] [PATCH] raw/ioat: fix dereference before null check
  2020-10-14 11:34 ` Bruce Richardson
@ 2020-10-19  8:24   ` Thomas Monjalon
  0 siblings, 0 replies; 3+ messages in thread
From: Thomas Monjalon @ 2020-10-19  8:24 UTC (permalink / raw)
  To: Kevin Laatz; +Cc: dev, Bruce Richardson

14/10/2020 13:34, Bruce Richardson:
> On Wed, Oct 14, 2020 at 11:11:10AM +0100, Kevin Laatz wrote:
> > 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 <kevin.laatz@intel.com>
> > ---
> Acked-by: Bruce Richardson <bruce.richardson@intel.com>

Applied, thanks



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-10-19  8:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-14 10:11 [dpdk-dev] [PATCH] raw/ioat: fix dereference before null check Kevin Laatz
2020-10-14 11:34 ` Bruce Richardson
2020-10-19  8:24   ` Thomas Monjalon

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).