mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrzej Hajda <a.hajda@samsung.com>
To: Inki Dae <inki.dae@samsung.com>
Cc: Andrzej Hajda <a.hajda@samsung.com>,
	Marek Szyprowski <m.szyprowski@samsung.com>,
	Joonyoung Shim <jy0922.shim@samsung.com>,
	Seung-Woo Kim <sw0312.kim@samsung.com>,
	Kyungmin Park <kyungmin.park@samsung.com>,
	dri-devel@lists.freedesktop.org,
	linux-kernel@vger.kernel.org (open list),
	linux-samsung-soc@vger.kernel.org (moderated list:ARM/S5P EXYNOS
	AR...)
Subject: [PATCH v2 06/17] drm/exynos/ipp: free partially allocated resources on error
Date: Thu, 28 Aug 2014 11:07:30 +0200	[thread overview]
Message-ID: <1409216861-12452-7-git-send-email-a.hajda@samsung.com> (raw)
In-Reply-To: <1409216861-12452-1-git-send-email-a.hajda@samsung.com>

In case of allocation errors some already allocated buffers
were not freed. The patch fixes it.

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
Reviewed-by: Joonyoung Shim <jy0922.shim@samsung.com>
---
 drivers/gpu/drm/exynos/exynos_drm_ipp.c | 67 ++++++++++++++++-----------------
 1 file changed, 32 insertions(+), 35 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_ipp.c b/drivers/gpu/drm/exynos/exynos_drm_ipp.c
index 060a198..ab7b74c 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_ipp.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_ipp.c
@@ -599,6 +599,35 @@ static int ipp_set_mem_node(struct exynos_drm_ippdrv *ippdrv,
 	return ret;
 }
 
+static int ipp_put_mem_node(struct drm_device *drm_dev,
+		struct drm_exynos_ipp_cmd_node *c_node,
+		struct drm_exynos_ipp_mem_node *m_node)
+{
+	int i;
+
+	DRM_DEBUG_KMS("node[0x%x]\n", (int)m_node);
+
+	if (!m_node) {
+		DRM_ERROR("invalid dequeue node.\n");
+		return -EFAULT;
+	}
+
+	DRM_DEBUG_KMS("ops_id[%d]\n", m_node->ops_id);
+
+	/* put gem buffer */
+	for_each_ipp_planar(i) {
+		unsigned long handle = m_node->buf_info.handles[i];
+		if (handle)
+			exynos_drm_gem_put_dma_addr(drm_dev, handle,
+							c_node->filp);
+	}
+
+	list_del(&m_node->list);
+	kfree(m_node);
+
+	return 0;
+}
+
 static struct drm_exynos_ipp_mem_node
 		*ipp_get_mem_node(struct drm_device *drm_dev,
 		struct drm_file *file,
@@ -619,6 +648,7 @@ static struct drm_exynos_ipp_mem_node
 	m_node->ops_id = qbuf->ops_id;
 	m_node->prop_id = qbuf->prop_id;
 	m_node->buf_id = qbuf->buf_id;
+	INIT_LIST_HEAD(&m_node->list);
 
 	DRM_DEBUG_KMS("m_node[0x%x]ops_id[%d]\n", (int)m_node, qbuf->ops_id);
 	DRM_DEBUG_KMS("prop_id[%d]buf_id[%d]\n", qbuf->prop_id, m_node->buf_id);
@@ -634,7 +664,8 @@ static struct drm_exynos_ipp_mem_node
 					qbuf->handle[i], file);
 			if (IS_ERR(addr)) {
 				DRM_ERROR("failed to get addr.\n");
-				goto err_clear;
+				ipp_put_mem_node(drm_dev, c_node, m_node);
+				return ERR_PTR(-EFAULT);
 			}
 
 			buf_info->handles[i] = qbuf->handle[i];
@@ -649,40 +680,6 @@ static struct drm_exynos_ipp_mem_node
 	mutex_unlock(&c_node->mem_lock);
 
 	return m_node;
-
-err_clear:
-	kfree(m_node);
-	return ERR_PTR(-EFAULT);
-}
-
-static int ipp_put_mem_node(struct drm_device *drm_dev,
-		struct drm_exynos_ipp_cmd_node *c_node,
-		struct drm_exynos_ipp_mem_node *m_node)
-{
-	int i;
-
-	DRM_DEBUG_KMS("node[0x%x]\n", (int)m_node);
-
-	if (!m_node) {
-		DRM_ERROR("invalid dequeue node.\n");
-		return -EFAULT;
-	}
-
-	DRM_DEBUG_KMS("ops_id[%d]\n", m_node->ops_id);
-
-	/* put gem buffer */
-	for_each_ipp_planar(i) {
-		unsigned long handle = m_node->buf_info.handles[i];
-		if (handle)
-			exynos_drm_gem_put_dma_addr(drm_dev, handle,
-							c_node->filp);
-	}
-
-	/* delete list in queue */
-	list_del(&m_node->list);
-	kfree(m_node);
-
-	return 0;
 }
 
 static void ipp_free_event(struct drm_pending_event *event)
-- 
1.9.1


  parent reply	other threads:[~2014-08-28  9:11 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-28  9:07 [PATCH v2 00/17] drm/exynos/ipp: image post processing fixes and improvements, part four Andrzej Hajda
2014-08-28  9:07 ` [PATCH v2 01/17] drm/exynos/ipp: remove fake pm callbacks Andrzej Hajda
2014-08-28  9:07 ` [PATCH v2 02/17] drm/exynos/ipp: cancel works before command node clean Andrzej Hajda
2014-08-28  9:07 ` [PATCH v2 03/17] drm/exynos/ipp: move file reference from memory to command node Andrzej Hajda
2014-08-28  9:07 ` [PATCH v2 04/17] drm/exynos/ipp: remove only related commands on file close Andrzej Hajda
2014-08-28  9:07 ` [PATCH v2 05/17] drm/exynos/ipp: remove unused field in command node Andrzej Hajda
2014-08-28  9:07 ` Andrzej Hajda [this message]
2014-08-28  9:07 ` [PATCH v2 07/17] drm/exynos/ipp: move nodes cleaning to separate function Andrzej Hajda
2014-08-28  9:07 ` [PATCH v2 08/17] drm/exynos/ipp: clean memory nodes on command node cleaning Andrzej Hajda
2014-08-28  9:07 ` [PATCH v2 09/17] drm/exynos/ipp: replace work_struct casting with better constructs Andrzej Hajda
2014-08-28  9:07 ` [PATCH v2 10/17] drm/exynos/ipp: stop hardware before freeing memory Andrzej Hajda
2014-08-28  9:07 ` [PATCH v2 11/17] drm/exynos/ipp: remove events during command cleaning Andrzej Hajda
2014-08-28  9:07 ` [PATCH v2 12/17] drm/exynos/fimc: avoid clearing overflow bits Andrzej Hajda
2014-08-28  9:07 ` [PATCH v2 13/17] drm/exynos/fimc: do not enable fimc twice Andrzej Hajda
2014-08-28  9:07 ` [PATCH v2 14/17] drm/exynos/fimc: simplify buffer queuing Andrzej Hajda
2014-08-28  9:07 ` [PATCH v2 15/17] drm/exynos/fimc: fix source buffer registers Andrzej Hajda
2014-08-28  9:07 ` [PATCH v2 16/17] drm/exynos/ipp: remove file argument from node related functions Andrzej Hajda
2014-08-29  7:03   ` Joonyoung Shim
2014-09-02 12:55   ` [PATCH v3 " Andrzej Hajda
2014-09-03  1:42     ` Joonyoung Shim
2014-08-28  9:07 ` [PATCH v2 17/17] drm/exynos/ipp: add file checks for ioctls Andrzej Hajda
2014-08-29  7:11   ` Joonyoung Shim
2014-09-02 12:56   ` [PATCH v3 " Andrzej Hajda
2014-09-11 12:50 ` [PATCH v2 00/17] drm/exynos/ipp: image post processing fixes and improvements, part four Inki Dae

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1409216861-12452-7-git-send-email-a.hajda@samsung.com \
    --to=a.hajda@samsung.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=inki.dae@samsung.com \
    --cc=jy0922.shim@samsung.com \
    --cc=kyungmin.park@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=sw0312.kim@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®