media: exynos4-is: Fix a use after free in isp_video_release
[linux-2.6-microblaze.git] / drivers / media / platform / exynos4-is / fimc-isp-video.c
index 612b987..83688a7 100644 (file)
@@ -275,7 +275,7 @@ static int isp_video_open(struct file *file)
        if (ret < 0)
                goto unlock;
 
-       ret = pm_runtime_get_sync(&isp->pdev->dev);
+       ret = pm_runtime_resume_and_get(&isp->pdev->dev);
        if (ret < 0)
                goto rel_fh;
 
@@ -293,7 +293,6 @@ static int isp_video_open(struct file *file)
        if (!ret)
                goto unlock;
 rel_fh:
-       pm_runtime_put_noidle(&isp->pdev->dev);
        v4l2_fh_release(file);
 unlock:
        mutex_unlock(&isp->video_lock);
@@ -306,17 +305,20 @@ static int isp_video_release(struct file *file)
        struct fimc_is_video *ivc = &isp->video_capture;
        struct media_entity *entity = &ivc->ve.vdev.entity;
        struct media_device *mdev = entity->graph_obj.mdev;
+       bool is_singular_file;
 
        mutex_lock(&isp->video_lock);
 
-       if (v4l2_fh_is_singular_file(file) && ivc->streaming) {
+       is_singular_file = v4l2_fh_is_singular_file(file);
+
+       if (is_singular_file && ivc->streaming) {
                media_pipeline_stop(entity);
                ivc->streaming = 0;
        }
 
        _vb2_fop_release(file, NULL);
 
-       if (v4l2_fh_is_singular_file(file)) {
+       if (is_singular_file) {
                fimc_pipeline_call(&ivc->ve, close);
 
                mutex_lock(&mdev->graph_mutex);