* [PATCH] drm/msm: Memory leak bug fix
@ 2017-12-04 13:05 Sharat Masetty
0 siblings, 0 replies; 3+ messages in thread
From: Sharat Masetty @ 2017-12-04 13:05 UTC (permalink / raw)
To: freedreno; +Cc: linux-arm-msm, Sharat Masetty, dri-devel
This patch fixes a possible memory leak in get_pages()
Prakash Kamliya (1):
drm/msm: fix leak in failed get_pages
drivers/gpu/drm/msm/msm_gem.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
--
1.9.1
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] drm/msm: Memory leak bug fix
@ 2017-12-04 13:40 Sharat Masetty
[not found] ` <1512394815-23838-1-git-send-email-smasetty-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: Sharat Masetty @ 2017-12-04 13:40 UTC (permalink / raw)
To: freedreno; +Cc: linux-arm-msm, Sharat Masetty, dri-devel
This patch fixes a possible memory leak in get_pages()
Prakash Kamliya (1):
drm/msm: fix leak in failed get_pages
drivers/gpu/drm/msm/msm_gem.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
--
1.9.1
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] drm/msm: fix leak in failed get_pages
[not found] ` <1512394815-23838-1-git-send-email-smasetty-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
@ 2017-12-04 13:40 ` Sharat Masetty
0 siblings, 0 replies; 3+ messages in thread
From: Sharat Masetty @ 2017-12-04 13:40 UTC (permalink / raw)
To: freedreno-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
Cc: linux-arm-msm-u79uwXL29TY76Z2rM5mHXA, Prakash Kamliya,
Sharat Masetty, dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
From: Prakash Kamliya <pkamliya@codeaurora.org>
get_pages doesn't keep a reference of the pages allocated
when it fails later in the code path. This can lead to
a memory leak. Keep reference of the allocated pages so
that it can be freed when msm_gem_free_object gets called
later during cleanup.
Signed-off-by: Prakash Kamliya <pkamliya@codeaurora.org>
Signed-off-by: Sharat Masetty <smasetty@codeaurora.org>
---
drivers/gpu/drm/msm/msm_gem.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c
index 0776160..cb3d58d 100644
--- a/drivers/gpu/drm/msm/msm_gem.c
+++ b/drivers/gpu/drm/msm/msm_gem.c
@@ -93,14 +93,17 @@ static struct page **get_pages(struct drm_gem_object *obj)
return p;
}
+ msm_obj->pages = p;
+
msm_obj->sgt = drm_prime_pages_to_sg(p, npages);
if (IS_ERR(msm_obj->sgt)) {
+ void *ptr = ERR_CAST(msm_obj->sgt);
+
dev_err(dev->dev, "failed to allocate sgt\n");
- return ERR_CAST(msm_obj->sgt);
+ msm_obj->sgt = NULL;
+ return ptr;
}
- msm_obj->pages = p;
-
/* For non-cached buffers, ensure the new pages are clean
* because display controller, GPU, etc. are not coherent:
*/
@@ -135,7 +138,10 @@ static void put_pages(struct drm_gem_object *obj)
if (msm_obj->flags & (MSM_BO_WC|MSM_BO_UNCACHED))
dma_unmap_sg(obj->dev->dev, msm_obj->sgt->sgl,
msm_obj->sgt->nents, DMA_BIDIRECTIONAL);
- sg_free_table(msm_obj->sgt);
+
+ if (msm_obj->sgt)
+ sg_free_table(msm_obj->sgt);
+
kfree(msm_obj->sgt);
if (use_pages(obj))
--
1.9.1
_______________________________________________
Freedreno mailing list
Freedreno@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/freedreno
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-12-04 13:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-04 13:40 [PATCH] drm/msm: Memory leak bug fix Sharat Masetty
[not found] ` <1512394815-23838-1-git-send-email-smasetty-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2017-12-04 13:40 ` [PATCH] drm/msm: fix leak in failed get_pages Sharat Masetty
-- strict thread matches above, loose matches on Subject: below --
2017-12-04 13:05 [PATCH] drm/msm: Memory leak bug fix Sharat Masetty
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox