Skip to contentSkip to conversation

media: s5p-g2d: Fix a memory leak on ctx->fh.m2m_ctx

PATCH New [email protected] 1 participant 1 message May 26, 2021 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 media: s5p-g2d: Fix a memory leak on ctx->fh.m2m_ctx

From: Dillon Min <[email protected]>

The m2m_ctx resources was allocated by v4l2_m2m_ctx_init() in g2d_open() should be freed from g2d_release() when it's not used.

Fix it

Fixes 918847341af0 ("[media] v4l: add G2D driver for s5p device family")

---

v2: move v4l2_m2m_ctx_release() up to v4l2_ctrl_handler() from Hans's
suggestion, thanks.

 drivers/media/platform/s5p-g2d/g2d.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/media/platform/s5p-g2d/g2d.c +3 -0
index 15bcb7f6e113..1cb5eaabf340 100644
@@ -276,6 +276,9 @@ static int g2d_release(struct file *file)
 	struct g2d_dev *dev = video_drvdata(file);
 	struct g2d_ctx *ctx = fh2ctx(file->private_data);
 
+	mutex_lock(&dev->mutex);
+	v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
+	mutex_unlock(&dev->mutex);
 	v4l2_ctrl_handler_free(&ctx->ctrl_handler);
 	v4l2_fh_del(&ctx->fh);
 	v4l2_fh_exit(&ctx->fh);
Signature · 1 line
1.9.1