Giter VIP home page Giter VIP logo

Comments (1)

hmaarrfk avatar hmaarrfk commented on July 29, 2024

Proposed patch:

From a432b7a86a14eefed708ca08669fdfcae9a76c66 Mon Sep 17 00:00:00 2001
From: Mark Harfouche <[email protected]>
Date: Mon, 20 May 2019 20:07:59 -0400
Subject: [PATCH] attemp to fixup early free of resources in xpdev_queue_delete

---
 QDMA/linux-kernel/drv/qdma_mod.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/QDMA/linux-kernel/drv/qdma_mod.c b/QDMA/linux-kernel/drv/qdma_mod.c
index 1557dc3..6552899 100644
--- a/QDMA/linux-kernel/drv/qdma_mod.c
+++ b/QDMA/linux-kernel/drv/qdma_mod.c
@@ -1547,7 +1547,7 @@ int xpdev_queue_delete(struct xlnx_pci_dev *xpdev, unsigned int qidx, bool c2h,
 {
 	struct xlnx_qdata *qdata = xpdev_queue_get(xpdev, qidx, c2h, 1, ebuf,
 						ebuflen);
-	int rv = 0;
+	int rv = 1;
 
 	if (!qdata)
 		return -EINVAL;
@@ -1555,12 +1555,6 @@ int xpdev_queue_delete(struct xlnx_pci_dev *xpdev, unsigned int qidx, bool c2h,
 	if(!qdata->xcdev)
 		return -EINVAL;
 
-	spin_lock(&xpdev->cdev_lock);
-	qdata->xcdev->dir_init &= ~(1 << (c2h ? 1 : 0));
-	if (qdata->xcdev && !qdata->xcdev->dir_init)
-		qdma_cdev_destroy(qdata->xcdev);
-	spin_unlock(&xpdev->cdev_lock);
-
 	if (qdata->qhndl != QDMA_QUEUE_IDX_INVALID)
 		rv = qdma_queue_remove(xpdev->dev_hndl, qdata->qhndl,
 					ebuf, ebuflen);
@@ -1570,6 +1564,13 @@ int xpdev_queue_delete(struct xlnx_pci_dev *xpdev, unsigned int qidx, bool c2h,
 	if (rv < 0)
 		goto exit;
 
+		// Optimistically remvoe the direction flag
+	spin_lock(&xpdev->cdev_lock);
+	qdata->xcdev->dir_init &= ~(1 << (c2h ? 1 : 0));
+	if (qdata->xcdev && !qdata->xcdev->dir_init)
+		qdma_cdev_destroy(qdata->xcdev);
+	spin_unlock(&xpdev->cdev_lock);
+
 	memset(qdata, 0, sizeof(*qdata));
 exit:
 	return rv;
-- 
2.21.0

comments are appreciated. Maybe we need to optimistically hide resources from other threads attempt to delete the queue, then revert if we fail????

from dma_ip_drivers.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.