[RAMEN9610-10029][COMMON] media: mfc: fix the potential memory leak
authorSunyoung Kang <sy0816.kang@samsung.com>
Thu, 25 Oct 2018 00:05:38 +0000 (09:05 +0900)
committerhskang <hs1218.kang@samsung.com>
Fri, 28 Dec 2018 09:54:03 +0000 (18:54 +0900)
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 <sy0816.kang@samsung.com>
drivers/media/platform/exynos/mfc/mfc_buf.c

index 1514d4ca8df760555c86e452c87d4adaba87f873..4d7d25f7109ccb43fec7bd7688057f73e6a20d9f 100644 (file)
@@ -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);