media: rockchip: ispp: fix system dead when access param/stats node without open stream

Signed-off-by: Hu Kejun <william.hu@rock-chips.com>
Change-Id: I12b3ba20c3b65c43ff4975a0603b70088ffcfbb2
This commit is contained in:
Hu Kejun
2020-03-26 21:02:43 +08:00
committed by Tao Huang
parent 3051dabb08
commit 261e809617
2 changed files with 76 additions and 5 deletions

View File

@@ -5,6 +5,7 @@
#include <media/v4l2-ioctl.h>
#include <media/videobuf2-core.h>
#include <media/videobuf2-vmalloc.h>
#include <media/v4l2-mc.h>
#include "dev.h"
#include "regs.h"
@@ -660,6 +661,42 @@ rkispp_params_vb2_start_streaming(struct vb2_queue *queue, unsigned int count)
return 0;
}
static int
rkispp_param_fh_open(struct file *filp)
{
struct rkispp_params_vdev *params = video_drvdata(filp);
struct rkispp_device *isppdev = params->dev;
int ret;
ret = v4l2_fh_open(filp);
if (!ret) {
ret = v4l2_pipeline_pm_use(&params->vnode.vdev.entity, 1);
if (ret < 0) {
v4l2_err(&isppdev->v4l2_dev,
"pipeline power on failed %d\n", ret);
vb2_fop_release(filp);
}
}
return ret;
}
static int
rkispp_param_fh_release(struct file *filp)
{
struct rkispp_params_vdev *params = video_drvdata(filp);
struct rkispp_device *isppdev = params->dev;
int ret;
ret = vb2_fop_release(filp);
if (!ret) {
ret = v4l2_pipeline_pm_use(&params->vnode.vdev.entity, 0);
if (ret < 0)
v4l2_err(&isppdev->v4l2_dev,
"pipeline power off failed %d\n", ret);
}
return ret;
}
static struct vb2_ops rkispp_params_vb2_ops = {
.queue_setup = rkispp_params_vb2_queue_setup,
.wait_prepare = vb2_ops_wait_prepare,
@@ -674,8 +711,8 @@ struct v4l2_file_operations rkispp_params_fops = {
.mmap = vb2_fop_mmap,
.unlocked_ioctl = video_ioctl2,
.poll = vb2_fop_poll,
.open = v4l2_fh_open,
.release = vb2_fop_release
.open = rkispp_param_fh_open,
.release = rkispp_param_fh_release,
};
static int

View File

@@ -7,6 +7,7 @@
#include <media/videobuf2-core.h>
#include <media/videobuf2-vmalloc.h> /* for ISP statistics */
#include <media/videobuf2-dma-contig.h>
#include <media/v4l2-mc.h>
#include "dev.h"
#include "regs.h"
#include "stats.h"
@@ -125,6 +126,40 @@ static int rkispp_stats_querycap(struct file *file,
return 0;
}
static int rkispp_stats_fh_open(struct file *filp)
{
struct rkispp_stats_vdev *stats = video_drvdata(filp);
struct rkispp_device *isppdev = stats->dev;
int ret;
ret = v4l2_fh_open(filp);
if (!ret) {
ret = v4l2_pipeline_pm_use(&stats->vnode.vdev.entity, 1);
if (ret < 0) {
v4l2_err(&isppdev->v4l2_dev,
"pipeline power on failed %d\n", ret);
vb2_fop_release(filp);
}
}
return ret;
}
static int rkispp_stats_fh_release(struct file *filp)
{
struct rkispp_stats_vdev *stats = video_drvdata(filp);
struct rkispp_device *isppdev = stats->dev;
int ret;
ret = vb2_fop_release(filp);
if (!ret) {
ret = v4l2_pipeline_pm_use(&stats->vnode.vdev.entity, 0);
if (ret < 0)
v4l2_err(&isppdev->v4l2_dev,
"pipeline power off failed %d\n", ret);
}
return ret;
}
/* ISP video device IOCTLs */
static const struct v4l2_ioctl_ops rkispp_stats_ioctl = {
.vidioc_reqbufs = vb2_ioctl_reqbufs,
@@ -147,8 +182,8 @@ struct v4l2_file_operations rkispp_stats_fops = {
.mmap = vb2_fop_mmap,
.unlocked_ioctl = video_ioctl2,
.poll = vb2_fop_poll,
.open = v4l2_fh_open,
.release = vb2_fop_release
.open = rkispp_stats_fh_open,
.release = rkispp_stats_fh_release,
};
static int rkispp_stats_vb2_queue_setup(struct vb2_queue *vq,
@@ -313,7 +348,6 @@ int rkispp_register_stats_vdev(struct rkispp_device *dev)
strlcpy(vdev->name, "rkispp-stats", sizeof(vdev->name));
video_set_drvdata(vdev, stats_vdev);
vdev->ioctl_ops = &rkispp_stats_ioctl;
vdev->fops = &rkispp_stats_fops;
vdev->release = video_device_release_empty;