mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] drm/msm: fix potential memleak issue
@ 2020-06-12  5:06 Bernard Zhao
  0 siblings, 0 replies; only message in thread
From: Bernard Zhao @ 2020-06-12  5:06 UTC (permalink / raw)
  To: Rob Clark, Sean Paul, David Airlie, Daniel Vetter, linux-arm-msm,
	dri-devel, freedreno, linux-kernel
  Cc: opensource.kernel, Bernard Zhao

Function msm_gpu_crashstate_capture maybe called for several
times, and then the state->bos is a potential memleak. Also
the state->pos maybe alloc failed, but now without any handle.
This change is to fix some potential memleak and add error
handle when alloc failed.

Signed-off-by: Bernard Zhao <bernard@vivo.com>
---
 drivers/gpu/drm/msm/msm_gpu.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/msm/msm_gpu.c b/drivers/gpu/drm/msm/msm_gpu.c
index a22d30622306..d67a9933f3ce 100644
--- a/drivers/gpu/drm/msm/msm_gpu.c
+++ b/drivers/gpu/drm/msm/msm_gpu.c
@@ -366,8 +366,11 @@ static void msm_gpu_crashstate_capture(struct msm_gpu *gpu,
 			if (!should_dump(submit, submit->cmd[i].idx))
 				nr++;
 
+		kfree(state->bos);
 		state->bos = kcalloc(nr,
 			sizeof(struct msm_gpu_state_bo), GFP_KERNEL);
+		if (!state->bos)
+			return;
 
 		for (i = 0; i < submit->nr_bos; i++) {
 			if (should_dump(submit, i)) {
-- 
2.17.1


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-06-12  5:06 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-12  5:06 [PATCH] drm/msm: fix potential memleak issue Bernard Zhao

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®