From: Sunyoung Kang Date: Thu, 25 Oct 2018 00:05:38 +0000 (+0900) Subject: [RAMEN9610-10029][COMMON] media: mfc: fix the potential memory leak X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=76f8aafa615952c157e6a8d433cd1ce2d6635b26;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git [RAMEN9610-10029][COMMON] media: mfc: fix the potential memory leak If user calls repeatedly s_fmt(), the roi_buffer will be re-allocated and it can be memory leak. So this add to check if it is already allocated. Change-Id: I0eea5f745c13630ce951f4c45109a01e92ddb7a9 Signed-off-by: Sunyoung Kang --- diff --git a/drivers/media/platform/exynos/mfc/mfc_buf.c b/drivers/media/platform/exynos/mfc/mfc_buf.c index 1514d4ca8df7..4d7d25f7109c 100644 --- a/drivers/media/platform/exynos/mfc/mfc_buf.c +++ b/drivers/media/platform/exynos/mfc/mfc_buf.c @@ -425,9 +425,11 @@ static int __mfc_alloc_enc_roi_buffer(struct mfc_ctx *ctx, struct mfc_special_bu roi_buf->buftype = MFCBUF_NORMAL; roi_buf->size = buf_size->shared_buf; - if (mfc_mem_ion_alloc(dev, roi_buf)) { - mfc_err_ctx("[ROI] Allocating ROI buffer failed\n"); - return -ENOMEM; + if (roi_buf->dma_buf == NULL) { + if (mfc_mem_ion_alloc(dev, roi_buf)) { + mfc_err_ctx("[ROI] Allocating ROI buffer failed\n"); + return -ENOMEM; + } } mfc_debug(2, "[MEMINFO][ROI] roi buf ctx[%d] size: %ld, daddr: 0x%08llx, vaddr: 0x%p\n", ctx->num, roi_buf->size, roi_buf->daddr, roi_buf->vaddr);