CHROMIUM: media: rockchip-isp1: cleanup alloc_ctx properly

Fix the memleak of alloc_ctx which is allocated twice and
doesn't cleanup properly.

BUG=b:71686724
TEST=check the kmemleak scan result

Change-Id: I17d15bf69bcdb33bb2cf6d446316d268a0df1e96
Signed-off-by: Shunqian Zheng <zhengsq@rock-chips.com>

Change-Id: I9a7e821b2d08c008a6a5a463953281ddee2ba245
Signed-off-by: Hu Kejun <william.hu@rock-chips.com>
This commit is contained in:
Hu Kejun
2018-03-27 18:37:32 +08:00
committed by Tao Huang
parent 8792e5c8ed
commit ce38205c50
2 changed files with 12 additions and 8 deletions

View File

@@ -1576,12 +1576,10 @@ static int rkisp1_s_selection(struct file *file, void *prv,
if (sel->flags != 0)
return -EINVAL;
if (sel->target == V4L2_SEL_TGT_CROP) {
*dcrop = *rkisp1_update_crop(stream, &sel->r, input_win);
v4l2_dbg(1, rkisp1_debug, &dev->v4l2_dev,
"stream %d crop(%d,%d)/%dx%d\n", stream->id,
dcrop->left, dcrop->top, dcrop->width, dcrop->height);
}
*dcrop = *rkisp1_update_crop(stream, &sel->r, input_win);
v4l2_dbg(1, rkisp1_debug, &dev->v4l2_dev,
"stream %d crop(%d,%d)/%dx%d\n", stream->id,
dcrop->left, dcrop->top, dcrop->width, dcrop->height);
return 0;
}
@@ -1661,7 +1659,6 @@ static int rkisp1_register_stream_vdev(struct rkisp1_stream *stream)
vdev->vfl_dir = VFL_DIR_RX;
node->pad.flags = MEDIA_PAD_FL_SINK;
dev->alloc_ctx = vb2_dma_contig_init_ctx(v4l2_dev->dev);
rkisp_init_vb2_queue(&node->buf_queue, stream,
V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE);
vdev->queue = &node->buf_queue;

View File

@@ -40,6 +40,7 @@
#include <linux/of_platform.h>
#include <linux/pm_runtime.h>
#include <linux/pinctrl/consumer.h>
#include <media/videobuf2-dma-contig.h>
#include <linux/dma-iommu.h>
#include "regs.h"
#include "rkisp1.h"
@@ -380,9 +381,11 @@ static int rkisp1_register_platform_subdevs(struct rkisp1_device *dev)
{
int ret;
dev->alloc_ctx = vb2_dma_contig_init_ctx(dev->v4l2_dev.dev);
ret = rkisp1_register_isp_subdev(dev, &dev->v4l2_dev);
if (ret < 0)
return ret;
goto err_cleanup_ctx;
ret = rkisp1_register_stream_vdevs(dev);
if (ret < 0)
@@ -413,6 +416,9 @@ err_unreg_stream_vdev:
rkisp1_unregister_stream_vdevs(dev);
err_unreg_isp_subdev:
rkisp1_unregister_isp_subdev(dev);
err_cleanup_ctx:
vb2_dma_contig_cleanup_ctx(dev->alloc_ctx);
return ret;
}
@@ -660,6 +666,7 @@ static int rkisp1_plat_remove(struct platform_device *pdev)
rkisp1_unregister_stats_vdev(&isp_dev->stats_vdev);
rkisp1_unregister_stream_vdevs(isp_dev);
rkisp1_unregister_isp_subdev(isp_dev);
vb2_dma_contig_cleanup_ctx(isp_dev->alloc_ctx);
return 0;
}