[PATCH v2 27/76] media: Reset file->private_data to NULL in v4l2_fh_del()

Partially applied
From:Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Date:
Message-ID:<20250809211654.28887-28-laurent.pinchart@ideasonboard.com>
Patch:v2 · 27/76
Language:zh_CN
Patch-ID:4e540c10b5c03c9f0f85010bb3861f1df8fd365a
Files:Documentation/driver-api/media/v4l2-fh.rstDocumentation/translations/zh_CN/video4linux/v4l2-framework.txtdrivers/media/pci/cx18/cx18-fileops.cdrivers/media/pci/ivtv/ivtv-fileops.cdrivers/media/pci/saa7164/saa7164-encoder.cdrivers/media/pci/saa7164/saa7164-vbi.cdrivers/media/platform/allegro-dvt/allegro-core.cdrivers/media/platform/amlogic/meson-ge2d/ge2d.cdrivers/media/platform/amphion/vpu_v4l2.cdrivers/media/platform/chips-media/coda/coda-common.cdrivers/media/platform/chips-media/wave5/wave5-helper.cdrivers/media/platform/imagination/e5010-jpeg-enc.cdrivers/media/platform/m2m-deinterlace.cdrivers/media/platform/mediatek/jpeg/mtk_jpeg_core.cdrivers/media/platform/mediatek/mdp/mtk_mdp_m2m.cdrivers/media/platform/mediatek/mdp3/mtk-mdp3-m2m.cdrivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.cdrivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc_drv.cdrivers/media/platform/nvidia/tegra-vde/v4l2.cdrivers/media/platform/nxp/dw100/dw100.cdrivers/media/platform/nxp/imx-jpeg/mxc-jpeg.cdrivers/media/platform/nxp/imx-pxp.cdrivers/media/platform/nxp/imx8-isi/imx8-isi-m2m.cdrivers/media/platform/nxp/mx2_emmaprp.cdrivers/media/platform/qcom/iris/iris_vidc.cdrivers/media/platform/qcom/venus/core.cdrivers/media/platform/renesas/rcar_fdp1.cdrivers/media/platform/renesas/rcar_jpu.cdrivers/media/platform/renesas/vsp1/vsp1_video.cdrivers/media/platform/rockchip/rga/rga.cdrivers/media/platform/rockchip/rkvdec/rkvdec.cdrivers/media/platform/samsung/exynos-gsc/gsc-m2m.cdrivers/media/platform/samsung/exynos4-is/fimc-m2m.cdrivers/media/platform/samsung/s5p-g2d/g2d.cdrivers/media/platform/samsung/s5p-jpeg/jpeg-core.cdrivers/media/platform/samsung/s5p-mfc/s5p_mfc.cdrivers/media/platform/st/sti/bdisp/bdisp-v4l2.cdrivers/media/platform/st/sti/delta/delta-v4l2.cdrivers/media/platform/st/sti/hva/hva-v4l2.cdrivers/media/platform/st/stm32/dma2d/dma2d.cdrivers/media/platform/sunxi/sun8i-di/sun8i-di.cdrivers/media/platform/sunxi/sun8i-rotate/sun8i_rotate.cdrivers/media/platform/ti/omap3isp/ispvideo.cdrivers/media/platform/ti/vpe/vpe.cdrivers/media/platform/verisilicon/hantro_drv.cdrivers/media/test-drivers/vicodec/vicodec-core.cdrivers/media/test-drivers/vim2m.cdrivers/media/test-drivers/visl/visl-core.cdrivers/media/usb/pvrusb2/pvrusb2-v4l2.cdrivers/media/v4l2-core/v4l2-fh.cdrivers/media/v4l2-core/v4l2-subdev.cdrivers/staging/media/imx/imx-media-csc-scaler.cdrivers/staging/media/meson/vdec/vdec.cdrivers/staging/media/sunxi/cedrus/cedrus.cdrivers/staging/most/video/video.cdrivers/usb/gadget/function/uvc_v4l2.cinclude/media/v4l2-fh.h

Patch content 57 changed files

From: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> Multiple drivers that use v4l2_fh and call v4l2_fh_del() manually resetthe file->private_data pointer to NULL in their video device .release()file operation handler. Move the code to the v4l2_fh_del() function toavoid direct access to file->private_data in drivers. This requiresadding a file pointer argument to the function. Changes to drivers have been generated with the following coccinellesemantic patch: @@expression fh;identifier filp;identifier release;type ret;@@ret release(..., struct file *filp, ...){	<...-	filp->private_data = NULL;	...-	v4l2_fh_del(fh);+	v4l2_fh_del(fh, filp);	...>} @@expression fh;identifier filp;identifier release;type ret;@@ret release(..., struct file *filp, ...){	<...-	v4l2_fh_del(fh);+	v4l2_fh_del(fh, filp);	...-	filp->private_data = NULL;	...>} @@expression fh;identifier filp;identifier release;type ret;@@ret release(..., struct file *filp, ...){	<...-	v4l2_fh_del(fh);+	v4l2_fh_del(fh, filp);	...>} Manual changes have been applied to Documentation/ to update the usagepatterns, to drivers/media/v4l2-core/v4l2-fh.c to update thev4l2_fh_del() prototype and reset file->private_data, and toinclude/media/v4l2-fh.h to update the v4l2_fh_del() function prototypeand its documentation. Additionally, white space issues have been fixed manually indrivers/usb/gadget/function/uvc_v4l2.c Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>--- Documentation/driver-api/media/v4l2-fh.rst                 | 4 ++-- .../translations/zh_CN/video4linux/v4l2-framework.txt      | 4 ++-- drivers/media/pci/cx18/cx18-fileops.c                      | 4 ++-- drivers/media/pci/ivtv/ivtv-fileops.c                      | 4 ++-- drivers/media/pci/saa7164/saa7164-encoder.c                | 2 +- drivers/media/pci/saa7164/saa7164-vbi.c                    | 2 +- drivers/media/platform/allegro-dvt/allegro-core.c          | 2 +- drivers/media/platform/amlogic/meson-ge2d/ge2d.c           | 2 +- drivers/media/platform/amphion/vpu_v4l2.c                  | 4 ++-- drivers/media/platform/chips-media/coda/coda-common.c      | 4 ++-- drivers/media/platform/chips-media/wave5/wave5-helper.c    | 2 +- drivers/media/platform/imagination/e5010-jpeg-enc.c        | 4 ++-- drivers/media/platform/m2m-deinterlace.c                   | 2 +- drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c       | 4 ++-- drivers/media/platform/mediatek/mdp/mtk_mdp_m2m.c          | 4 ++-- drivers/media/platform/mediatek/mdp3/mtk-mdp3-m2m.c        | 4 ++-- .../platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c  | 4 ++-- .../platform/mediatek/vcodec/encoder/mtk_vcodec_enc_drv.c  | 4 ++-- drivers/media/platform/nvidia/tegra-vde/v4l2.c             | 2 +- drivers/media/platform/nxp/dw100/dw100.c                   | 2 +- drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c             | 4 ++-- drivers/media/platform/nxp/imx-pxp.c                       | 2 +- drivers/media/platform/nxp/imx8-isi/imx8-isi-m2m.c         | 2 +- drivers/media/platform/nxp/mx2_emmaprp.c                   | 2 +- drivers/media/platform/qcom/iris/iris_vidc.c               | 3 +-- drivers/media/platform/qcom/venus/core.c                   | 2 +- drivers/media/platform/renesas/rcar_fdp1.c                 | 2 +- drivers/media/platform/renesas/rcar_jpu.c                  | 4 ++-- drivers/media/platform/renesas/vsp1/vsp1_video.c           | 2 +- drivers/media/platform/rockchip/rga/rga.c                  | 2 +- drivers/media/platform/rockchip/rkvdec/rkvdec.c            | 2 +- drivers/media/platform/samsung/exynos-gsc/gsc-m2m.c        | 4 ++-- drivers/media/platform/samsung/exynos4-is/fimc-m2m.c       | 4 ++-- drivers/media/platform/samsung/s5p-g2d/g2d.c               | 2 +- drivers/media/platform/samsung/s5p-jpeg/jpeg-core.c        | 4 ++-- drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c           | 4 ++-- drivers/media/platform/st/sti/bdisp/bdisp-v4l2.c           | 4 ++-- drivers/media/platform/st/sti/delta/delta-v4l2.c           | 4 ++-- drivers/media/platform/st/sti/hva/hva-v4l2.c               | 4 ++-- drivers/media/platform/st/stm32/dma2d/dma2d.c              | 2 +- drivers/media/platform/sunxi/sun8i-di/sun8i-di.c           | 2 +- drivers/media/platform/sunxi/sun8i-rotate/sun8i_rotate.c   | 2 +- drivers/media/platform/ti/omap3isp/ispvideo.c              | 5 ++--- drivers/media/platform/ti/vpe/vpe.c                        | 2 +- drivers/media/platform/verisilicon/hantro_drv.c            | 4 ++-- drivers/media/test-drivers/vicodec/vicodec-core.c          | 2 +- drivers/media/test-drivers/vim2m.c                         | 2 +- drivers/media/test-drivers/visl/visl-core.c                | 2 +- drivers/media/usb/pvrusb2/pvrusb2-v4l2.c                   | 3 +-- drivers/media/v4l2-core/v4l2-fh.c                          | 7 ++++--- drivers/media/v4l2-core/v4l2-subdev.c                      | 5 ++--- drivers/staging/media/imx/imx-media-csc-scaler.c           | 4 ++-- drivers/staging/media/meson/vdec/vdec.c                    | 2 +- drivers/staging/media/sunxi/cedrus/cedrus.c                | 2 +- drivers/staging/most/video/video.c                         | 4 ++-- drivers/usb/gadget/function/uvc_v4l2.c                     | 3 +-- include/media/v4l2-fh.h                                    | 5 ++++- 57 files changed, 89 insertions(+), 90 deletions(-) diff --git a/Documentation/driver-api/media/v4l2-fh.rst b/Documentation/driver-api/media/v4l2-fh.rstindex a7393067f5db..afcad22ead7c 100644--- a/Documentation/driver-api/media/v4l2-fh.rst+++ b/Documentation/driver-api/media/v4l2-fh.rst@@ -65,7 +65,7 @@ Example: 		struct my_fh *my_fh = container_of(fh, struct my_fh, fh);  		...-		v4l2_fh_del(&my_fh->fh);+		v4l2_fh_del(&my_fh->fh, file); 		v4l2_fh_exit(&my_fh->fh); 		kfree(my_fh); 		return 0;@@ -86,7 +86,7 @@ Below is a short description of the :c:type:`v4l2_fh` functions used:   Must be called once the file handle is completely initialized.  :c:func:`v4l2_fh_del <v4l2_fh_del>`-(:c:type:`fh <v4l2_fh>`)+(:c:type:`fh <v4l2_fh>`, struct file \*filp)  - Unassociate the file handle from :c:type:`video_device`. The file handle   exit function may now be called.diff --git a/Documentation/translations/zh_CN/video4linux/v4l2-framework.txt b/Documentation/translations/zh_CN/video4linux/v4l2-framework.txtindex 2d38ae17d940..1653c6e2cb46 100644--- a/Documentation/translations/zh_CN/video4linux/v4l2-framework.txt+++ b/Documentation/translations/zh_CN/video4linux/v4l2-framework.txt@@ -822,7 +822,7 @@ int my_release(struct file *file) 	struct my_fh *my_fh = container_of(fh, struct my_fh, fh);  	...-	v4l2_fh_del(&my_fh->fh);+	v4l2_fh_del(&my_fh->fh, file); 	v4l2_fh_exit(&my_fh->fh); 	kfree(my_fh); 	return 0;@@ -840,7 +840,7 @@ void v4l2_fh_add(struct v4l2_fh *fh, struct file *filp)   添加一个 v4l2_fh 到 video_device 文件句柄列表。一旦文件句柄   初始化完成就必须调用。 -void v4l2_fh_del(struct v4l2_fh *fh)+void v4l2_fh_del(struct v4l2_fh *fh, struct file *filp)    从 video_device() 中解除文件句柄的关联。文件句柄的退出函数也   将被调用。diff --git a/drivers/media/pci/cx18/cx18-fileops.c b/drivers/media/pci/cx18/cx18-fileops.cindex f90b547f5d67..d49fa4c4119b 100644--- a/drivers/media/pci/cx18/cx18-fileops.c+++ b/drivers/media/pci/cx18/cx18-fileops.c@@ -713,7 +713,7 @@ int cx18_v4l2_close(struct file *filp) 		vb2_queue_release(vdev->queue); 		vdev->queue->owner = NULL; 	}-	v4l2_fh_del(fh);+	v4l2_fh_del(fh, filp); 	v4l2_fh_exit(fh);  	/* 'Unclaim' this stream */@@ -751,7 +751,7 @@ static int cx18_serialized_open(struct cx18_stream *s, struct file *filp) 			if (atomic_read(&cx->ana_capturing) > 0) { 				/* switching to radio while capture is 				   in progress is not polite */-				v4l2_fh_del(&item->fh);+				v4l2_fh_del(&item->fh, filp); 				v4l2_fh_exit(&item->fh); 				kfree(item); 				return -EBUSY;diff --git a/drivers/media/pci/ivtv/ivtv-fileops.c b/drivers/media/pci/ivtv/ivtv-fileops.cindex aa5f5f16427c..0040a5e7f654 100644--- a/drivers/media/pci/ivtv/ivtv-fileops.c+++ b/drivers/media/pci/ivtv/ivtv-fileops.c@@ -911,7 +911,7 @@ int ivtv_v4l2_close(struct file *filp) 		ivtv_unmute(itv); 	} -	v4l2_fh_del(fh);+	v4l2_fh_del(fh, filp); 	v4l2_fh_exit(fh);  	/* Easy case first: this stream was never claimed by us */@@ -1006,7 +1006,7 @@ static int ivtv_open(struct file *filp) 			if (atomic_read(&itv->capturing) > 0) { 				/* switching to radio while capture is 				   in progress is not polite */-				v4l2_fh_del(&item->fh);+				v4l2_fh_del(&item->fh, filp); 				v4l2_fh_exit(&item->fh); 				kfree(item); 				return -EBUSY;diff --git a/drivers/media/pci/saa7164/saa7164-encoder.c b/drivers/media/pci/saa7164/saa7164-encoder.cindex e6e353a251cf..66d650b5f69a 100644--- a/drivers/media/pci/saa7164/saa7164-encoder.c+++ b/drivers/media/pci/saa7164/saa7164-encoder.c@@ -746,7 +746,7 @@ static int fops_release(struct file *file) 		} 	} -	v4l2_fh_del(&fh->fh);+	v4l2_fh_del(&fh->fh, file); 	v4l2_fh_exit(&fh->fh); 	kfree(fh); diff --git a/drivers/media/pci/saa7164/saa7164-vbi.c b/drivers/media/pci/saa7164/saa7164-vbi.cindex 181442fcb43b..57e4362c0d19 100644--- a/drivers/media/pci/saa7164/saa7164-vbi.c+++ b/drivers/media/pci/saa7164/saa7164-vbi.c@@ -449,7 +449,7 @@ static int fops_release(struct file *file) 		} 	} -	v4l2_fh_del(&fh->fh);+	v4l2_fh_del(&fh->fh, file); 	v4l2_fh_exit(&fh->fh); 	kfree(fh); diff --git a/drivers/media/platform/allegro-dvt/allegro-core.c b/drivers/media/platform/allegro-dvt/allegro-core.cindex 8c30f3cd4fc5..5e3b1f5d7206 100644--- a/drivers/media/platform/allegro-dvt/allegro-core.c+++ b/drivers/media/platform/allegro-dvt/allegro-core.c@@ -3241,7 +3241,7 @@ static int allegro_release(struct file *file)  	v4l2_ctrl_handler_free(&channel->ctrl_handler); -	v4l2_fh_del(&channel->fh);+	v4l2_fh_del(&channel->fh, file); 	v4l2_fh_exit(&channel->fh);  	kfree(channel);diff --git a/drivers/media/platform/amlogic/meson-ge2d/ge2d.c b/drivers/media/platform/amlogic/meson-ge2d/ge2d.cindex d36891b546bc..b1b0b6535fb1 100644--- a/drivers/media/platform/amlogic/meson-ge2d/ge2d.c+++ b/drivers/media/platform/amlogic/meson-ge2d/ge2d.c@@ -883,7 +883,7 @@ static int ge2d_release(struct file *file) 	v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);  	v4l2_ctrl_handler_free(&ctx->ctrl_handler);-	v4l2_fh_del(&ctx->fh);+	v4l2_fh_del(&ctx->fh, file); 	v4l2_fh_exit(&ctx->fh); 	kfree(ctx); diff --git a/drivers/media/platform/amphion/vpu_v4l2.c b/drivers/media/platform/amphion/vpu_v4l2.cindex e13bfe09af1b..fcb2eff813ac 100644--- a/drivers/media/platform/amphion/vpu_v4l2.c+++ b/drivers/media/platform/amphion/vpu_v4l2.c@@ -791,7 +791,7 @@ int vpu_v4l2_open(struct file *file, struct vpu_inst *inst)  	return 0; error:-	v4l2_fh_del(&inst->fh);+	v4l2_fh_del(&inst->fh, file); 	v4l2_fh_exit(&inst->fh); 	vpu_inst_put(inst); 	return ret;@@ -812,7 +812,7 @@ int vpu_v4l2_close(struct file *file) 	call_void_vop(inst, release); 	vpu_inst_unlock(inst); -	v4l2_fh_del(&inst->fh);+	v4l2_fh_del(&inst->fh, file); 	v4l2_fh_exit(&inst->fh);  	vpu_inst_unregister(inst);diff --git a/drivers/media/platform/chips-media/coda/coda-common.c b/drivers/media/platform/chips-media/coda/coda-common.cindex 7d874fd502b8..583759eed610 100644--- a/drivers/media/platform/chips-media/coda/coda-common.c+++ b/drivers/media/platform/chips-media/coda/coda-common.c@@ -2725,7 +2725,7 @@ static int coda_open(struct file *file) err_clk_enable: 	pm_runtime_put_sync(dev->dev); err_pm_get:-	v4l2_fh_del(&ctx->fh);+	v4l2_fh_del(&ctx->fh, file); 	v4l2_fh_exit(&ctx->fh); err_coda_name_init: 	ida_free(&dev->ida, ctx->idx);@@ -2763,7 +2763,7 @@ static int coda_release(struct file *file) 	clk_disable_unprepare(dev->clk_ahb); 	clk_disable_unprepare(dev->clk_per); 	pm_runtime_put_sync(dev->dev);-	v4l2_fh_del(&ctx->fh);+	v4l2_fh_del(&ctx->fh, file); 	v4l2_fh_exit(&ctx->fh); 	ida_free(&dev->ida, ctx->idx); 	if (ctx->ops->release)diff --git a/drivers/media/platform/chips-media/wave5/wave5-helper.c b/drivers/media/platform/chips-media/wave5/wave5-helper.cindex ed8ff04a899d..0bce62f0c039 100644--- a/drivers/media/platform/chips-media/wave5/wave5-helper.c+++ b/drivers/media/platform/chips-media/wave5/wave5-helper.c@@ -46,7 +46,7 @@ void wave5_cleanup_instance(struct vpu_instance *inst, struct file *filp) 	wave5_vdi_free_dma_memory(inst->dev, &inst->bitstream_vbuf); 	v4l2_ctrl_handler_free(&inst->v4l2_ctrl_hdl); 	if (inst->v4l2_fh.vdev) {-		v4l2_fh_del(&inst->v4l2_fh);+		v4l2_fh_del(&inst->v4l2_fh, filp); 		v4l2_fh_exit(&inst->v4l2_fh); 	} 	list_del_init(&inst->list);diff --git a/drivers/media/platform/imagination/e5010-jpeg-enc.c b/drivers/media/platform/imagination/e5010-jpeg-enc.cindex 1da00ff4b1e3..c4e0097cb8b7 100644--- a/drivers/media/platform/imagination/e5010-jpeg-enc.c+++ b/drivers/media/platform/imagination/e5010-jpeg-enc.c@@ -769,7 +769,7 @@ static int e5010_open(struct file *file) err_ctrls_setup: 	v4l2_m2m_ctx_release(ctx->fh.m2m_ctx); exit:-	v4l2_fh_del(&ctx->fh);+	v4l2_fh_del(&ctx->fh, file); 	v4l2_fh_exit(&ctx->fh); 	mutex_unlock(&e5010->mutex); free:@@ -786,7 +786,7 @@ static int e5010_release(struct file *file) 	mutex_lock(&e5010->mutex); 	v4l2_ctrl_handler_free(&ctx->ctrl_handler); 	v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);-	v4l2_fh_del(&ctx->fh);+	v4l2_fh_del(&ctx->fh, file); 	v4l2_fh_exit(&ctx->fh); 	kfree(ctx); 	mutex_unlock(&e5010->mutex);diff --git a/drivers/media/platform/m2m-deinterlace.c b/drivers/media/platform/m2m-deinterlace.cindex a343dffd19f0..51c2f206cb1f 100644--- a/drivers/media/platform/m2m-deinterlace.c+++ b/drivers/media/platform/m2m-deinterlace.c@@ -880,7 +880,7 @@ static int deinterlace_release(struct file *file)  	dprintk(pcdev, "Releasing instance %p\n", ctx); -	v4l2_fh_del(&ctx->fh);+	v4l2_fh_del(&ctx->fh, file); 	v4l2_fh_exit(&ctx->fh); 	v4l2_m2m_ctx_release(ctx->fh.m2m_ctx); 	kfree(ctx->xt);diff --git a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.cindex 5178a1b170fe..de15d6f0b490 100644--- a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c+++ b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c@@ -1201,7 +1201,7 @@ static int mtk_jpeg_open(struct file *file) 	return 0;  error:-	v4l2_fh_del(&ctx->fh);+	v4l2_fh_del(&ctx->fh, file); 	v4l2_fh_exit(&ctx->fh); 	mutex_unlock(&jpeg->lock); free:@@ -1217,7 +1217,7 @@ static int mtk_jpeg_release(struct file *file) 	mutex_lock(&jpeg->lock); 	v4l2_m2m_ctx_release(ctx->fh.m2m_ctx); 	v4l2_ctrl_handler_free(&ctx->ctrl_hdl);-	v4l2_fh_del(&ctx->fh);+	v4l2_fh_del(&ctx->fh, file); 	v4l2_fh_exit(&ctx->fh); 	kfree(ctx); 	mutex_unlock(&jpeg->lock);diff --git a/drivers/media/platform/mediatek/mdp/mtk_mdp_m2m.c b/drivers/media/platform/mediatek/mdp/mtk_mdp_m2m.cindex 7a1a8e51dbca..7e89a8443707 100644--- a/drivers/media/platform/mediatek/mdp/mtk_mdp_m2m.c+++ b/drivers/media/platform/mediatek/mdp/mtk_mdp_m2m.c@@ -1130,7 +1130,7 @@ static int mtk_mdp_m2m_open(struct file *file) error_m2m_ctx: 	v4l2_ctrl_handler_free(&ctx->ctrl_handler); error_ctrls:-	v4l2_fh_del(&ctx->fh);+	v4l2_fh_del(&ctx->fh, file); 	v4l2_fh_exit(&ctx->fh); 	mutex_unlock(&mdp->lock); err_lock:@@ -1148,7 +1148,7 @@ static int mtk_mdp_m2m_release(struct file *file) 	mutex_lock(&mdp->lock); 	v4l2_m2m_ctx_release(ctx->m2m_ctx); 	v4l2_ctrl_handler_free(&ctx->ctrl_handler);-	v4l2_fh_del(&ctx->fh);+	v4l2_fh_del(&ctx->fh, file); 	v4l2_fh_exit(&ctx->fh); 	mtk_mdp_vpu_deinit(&ctx->vpu); 	mdp->ctx_num--;diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-m2m.c b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-m2m.cindex 847d6b310e74..e68ae19d71a9 100644--- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-m2m.c+++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-m2m.c@@ -633,7 +633,7 @@ static int mdp_m2m_open(struct file *file) 	v4l2_m2m_ctx_release(ctx->m2m_ctx); err_release_handler: 	v4l2_ctrl_handler_free(&ctx->ctrl_handler);-	v4l2_fh_del(&ctx->fh);+	v4l2_fh_del(&ctx->fh, file); err_exit_fh: 	v4l2_fh_exit(&ctx->fh); 	ida_free(&mdp->mdp_ida, ctx->id);@@ -657,7 +657,7 @@ static int mdp_m2m_release(struct file *file) 		mdp_vpu_put_locked(mdp);  	v4l2_ctrl_handler_free(&ctx->ctrl_handler);-	v4l2_fh_del(&ctx->fh);+	v4l2_fh_del(&ctx->fh, file); 	v4l2_fh_exit(&ctx->fh); 	ida_free(&mdp->mdp_ida, ctx->id); 	mutex_unlock(&mdp->m2m_lock);diff --git a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.cindex 952a77c383bd..46d176e6de63 100644--- a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c+++ b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c@@ -282,7 +282,7 @@ static int fops_vcodec_open(struct file *file) err_m2m_ctx_init: 	v4l2_ctrl_handler_free(&ctx->ctrl_hdl); err_ctrls_setup:-	v4l2_fh_del(&ctx->fh);+	v4l2_fh_del(&ctx->fh, file); 	v4l2_fh_exit(&ctx->fh); 	kfree(ctx); 	mutex_unlock(&dev->dev_mutex);@@ -307,7 +307,7 @@ static int fops_vcodec_release(struct file *file) 	v4l2_m2m_ctx_release(ctx->m2m_ctx); 	mtk_vcodec_dec_release(ctx); -	v4l2_fh_del(&ctx->fh);+	v4l2_fh_del(&ctx->fh, file); 	v4l2_fh_exit(&ctx->fh); 	v4l2_ctrl_handler_free(&ctx->ctrl_hdl); diff --git a/drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc_drv.c b/drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc_drv.cindex 9cacb6cbcf28..fb1c3bdc2dae 100644--- a/drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc_drv.c+++ b/drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc_drv.c@@ -191,7 +191,7 @@ static int fops_vcodec_open(struct file *file) err_m2m_ctx_init: 	v4l2_ctrl_handler_free(&ctx->ctrl_hdl); err_ctrls_setup:-	v4l2_fh_del(&ctx->fh);+	v4l2_fh_del(&ctx->fh, file); 	v4l2_fh_exit(&ctx->fh); 	kfree(ctx); 	mutex_unlock(&dev->dev_mutex);@@ -209,7 +209,7 @@ static int fops_vcodec_release(struct file *file)  	v4l2_m2m_ctx_release(ctx->m2m_ctx); 	mtk_vcodec_enc_release(ctx);-	v4l2_fh_del(&ctx->fh);+	v4l2_fh_del(&ctx->fh, file); 	v4l2_fh_exit(&ctx->fh); 	v4l2_ctrl_handler_free(&ctx->ctrl_hdl); diff --git a/drivers/media/platform/nvidia/tegra-vde/v4l2.c b/drivers/media/platform/nvidia/tegra-vde/v4l2.cindex 688b776b3010..0c50f4ff82e0 100644--- a/drivers/media/platform/nvidia/tegra-vde/v4l2.c+++ b/drivers/media/platform/nvidia/tegra-vde/v4l2.c@@ -856,7 +856,7 @@ static int tegra_release(struct file *file) 	struct tegra_ctx *ctx = fh_to_tegra_ctx(fh); 	struct tegra_vde *vde = ctx->vde; -	v4l2_fh_del(fh);+	v4l2_fh_del(fh, file); 	v4l2_m2m_ctx_release(fh->m2m_ctx); 	v4l2_ctrl_handler_free(&ctx->hdl); 	v4l2_fh_exit(fh);diff --git a/drivers/media/platform/nxp/dw100/dw100.c b/drivers/media/platform/nxp/dw100/dw100.cindex 2bd30910ddf9..97744c7b7c03 100644--- a/drivers/media/platform/nxp/dw100/dw100.c+++ b/drivers/media/platform/nxp/dw100/dw100.c@@ -667,7 +667,7 @@ static int dw100_release(struct file *file) { 	struct dw100_ctx *ctx = dw100_file2ctx(file); -	v4l2_fh_del(&ctx->fh);+	v4l2_fh_del(&ctx->fh, file); 	v4l2_fh_exit(&ctx->fh); 	v4l2_ctrl_handler_free(&ctx->hdl); 	v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);diff --git a/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c b/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.cindex d7cecc56a9eb..a34e644b2cb1 100644--- a/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c+++ b/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c@@ -2238,7 +2238,7 @@ static int mxc_jpeg_open(struct file *file) err_ctrls_setup: 	v4l2_m2m_ctx_release(ctx->fh.m2m_ctx); error:-	v4l2_fh_del(&ctx->fh);+	v4l2_fh_del(&ctx->fh, file); 	v4l2_fh_exit(&ctx->fh); 	mutex_unlock(&mxc_jpeg->lock); free:@@ -2751,7 +2751,7 @@ static int mxc_jpeg_release(struct file *file) 			ctx->slot); 	v4l2_ctrl_handler_free(&ctx->ctrl_handler); 	v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);-	v4l2_fh_del(&ctx->fh);+	v4l2_fh_del(&ctx->fh, file); 	v4l2_fh_exit(&ctx->fh); 	kfree(ctx); 	mutex_unlock(&mxc_jpeg->lock);diff --git a/drivers/media/platform/nxp/imx-pxp.c b/drivers/media/platform/nxp/imx-pxp.cindex 9602409f3ece..6cc9b07ea53a 100644--- a/drivers/media/platform/nxp/imx-pxp.c+++ b/drivers/media/platform/nxp/imx-pxp.c@@ -1716,7 +1716,7 @@ static int pxp_release(struct file *file)  	dprintk(dev, "Releasing instance %p\n", ctx); -	v4l2_fh_del(&ctx->fh);+	v4l2_fh_del(&ctx->fh, file); 	v4l2_fh_exit(&ctx->fh); 	v4l2_ctrl_handler_free(&ctx->hdl); 	mutex_lock(&dev->dev_mutex);diff --git a/drivers/media/platform/nxp/imx8-isi/imx8-isi-m2m.c b/drivers/media/platform/nxp/imx8-isi/imx8-isi-m2m.cindex d6df6e2725f5..31298307c672 100644--- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-m2m.c+++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-m2m.c@@ -716,7 +716,7 @@ static int mxc_isi_m2m_release(struct file *file) 	v4l2_m2m_ctx_release(ctx->fh.m2m_ctx); 	mxc_isi_m2m_ctx_ctrls_delete(ctx); -	v4l2_fh_del(&ctx->fh);+	v4l2_fh_del(&ctx->fh, file); 	v4l2_fh_exit(&ctx->fh);  	mutex_destroy(&ctx->vb2_lock);diff --git a/drivers/media/platform/nxp/mx2_emmaprp.c b/drivers/media/platform/nxp/mx2_emmaprp.cindex 8c8f834e6250..d23da93304bd 100644--- a/drivers/media/platform/nxp/mx2_emmaprp.c+++ b/drivers/media/platform/nxp/mx2_emmaprp.c@@ -769,7 +769,7 @@ static int emmaprp_release(struct file *file) 	mutex_lock(&pcdev->dev_mutex); 	clk_disable_unprepare(pcdev->clk_emma_ahb); 	clk_disable_unprepare(pcdev->clk_emma_ipg);-	v4l2_fh_del(&ctx->fh);+	v4l2_fh_del(&ctx->fh, file); 	v4l2_fh_exit(&ctx->fh); 	v4l2_m2m_ctx_release(ctx->fh.m2m_ctx); 	mutex_unlock(&pcdev->dev_mutex);diff --git a/drivers/media/platform/qcom/iris/iris_vidc.c b/drivers/media/platform/qcom/iris/iris_vidc.cindex cdd34a3b71ff..541ae86f7892 100644--- a/drivers/media/platform/qcom/iris/iris_vidc.c+++ b/drivers/media/platform/qcom/iris/iris_vidc.c@@ -30,8 +30,7 @@ static void iris_v4l2_fh_init(struct iris_inst *inst, struct file *filp)  static void iris_v4l2_fh_deinit(struct iris_inst *inst, struct file *filp) {-	filp->private_data = NULL;-	v4l2_fh_del(&inst->fh);+	v4l2_fh_del(&inst->fh, filp); 	inst->fh.ctrl_handler = NULL; 	v4l2_fh_exit(&inst->fh); }diff --git a/drivers/media/platform/qcom/venus/core.c b/drivers/media/platform/qcom/venus/core.cindex 5e1ace16a490..90de29f166ad 100644--- a/drivers/media/platform/qcom/venus/core.c+++ b/drivers/media/platform/qcom/venus/core.c@@ -607,7 +607,7 @@ void venus_close_common(struct venus_inst *inst, struct file *filp) 	v4l2_m2m_ctx_release(inst->m2m_ctx); 	v4l2_m2m_release(inst->m2m_dev); 	hfi_session_destroy(inst);-	v4l2_fh_del(&inst->fh);+	v4l2_fh_del(&inst->fh, filp); 	v4l2_fh_exit(&inst->fh); 	v4l2_ctrl_handler_free(&inst->ctrl_handler); diff --git a/drivers/media/platform/renesas/rcar_fdp1.c b/drivers/media/platform/renesas/rcar_fdp1.cindex f1ea303ac038..e2dba0e4f315 100644--- a/drivers/media/platform/renesas/rcar_fdp1.c+++ b/drivers/media/platform/renesas/rcar_fdp1.c@@ -2166,7 +2166,7 @@ static int fdp1_release(struct file *file)  	dprintk(fdp1, "Releasing instance %p\n", ctx); -	v4l2_fh_del(&ctx->fh);+	v4l2_fh_del(&ctx->fh, file); 	v4l2_fh_exit(&ctx->fh); 	v4l2_ctrl_handler_free(&ctx->hdl); 	mutex_lock(&fdp1->dev_mutex);diff --git a/drivers/media/platform/renesas/rcar_jpu.c b/drivers/media/platform/renesas/rcar_jpu.cindex d0d4ee3f8bdc..0b479dfa2917 100644--- a/drivers/media/platform/renesas/rcar_jpu.c+++ b/drivers/media/platform/renesas/rcar_jpu.c@@ -1276,7 +1276,7 @@ static int jpu_open(struct file *file) device_prepare_rollback: 	mutex_unlock(&jpu->mutex); v4l_prepare_rollback:-	v4l2_fh_del(&ctx->fh);+	v4l2_fh_del(&ctx->fh, file); 	v4l2_fh_exit(&ctx->fh); 	kfree(ctx); 	return ret;@@ -1289,7 +1289,7 @@ static int jpu_release(struct file *file)  	v4l2_m2m_ctx_release(ctx->fh.m2m_ctx); 	v4l2_ctrl_handler_free(&ctx->ctrl_handler);-	v4l2_fh_del(&ctx->fh);+	v4l2_fh_del(&ctx->fh, file); 	v4l2_fh_exit(&ctx->fh); 	kfree(ctx); diff --git a/drivers/media/platform/renesas/vsp1/vsp1_video.c b/drivers/media/platform/renesas/vsp1/vsp1_video.cindex b6dc1ee3dc50..75f9a1a85d55 100644--- a/drivers/media/platform/renesas/vsp1/vsp1_video.c+++ b/drivers/media/platform/renesas/vsp1/vsp1_video.c@@ -1083,7 +1083,7 @@ static int vsp1_video_open(struct file *file)  	ret = vsp1_device_get(video->vsp1); 	if (ret < 0) {-		v4l2_fh_del(vfh);+		v4l2_fh_del(vfh, file); 		v4l2_fh_exit(vfh); 		kfree(vfh); 	}diff --git a/drivers/media/platform/rockchip/rga/rga.c b/drivers/media/platform/rockchip/rga/rga.cindex d88817023996..45c42c7ad846 100644--- a/drivers/media/platform/rockchip/rga/rga.c+++ b/drivers/media/platform/rockchip/rga/rga.c@@ -418,7 +418,7 @@ static int rga_release(struct file *file) 	v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);  	v4l2_ctrl_handler_free(&ctx->ctrl_handler);-	v4l2_fh_del(&ctx->fh);+	v4l2_fh_del(&ctx->fh, file); 	v4l2_fh_exit(&ctx->fh); 	kfree(ctx); diff --git a/drivers/media/platform/rockchip/rkvdec/rkvdec.c b/drivers/media/platform/rockchip/rkvdec/rkvdec.cindex 2fbad685e92c..481c2488f9ac 100644--- a/drivers/media/platform/rockchip/rkvdec/rkvdec.c+++ b/drivers/media/platform/rockchip/rkvdec/rkvdec.c@@ -954,7 +954,7 @@ static int rkvdec_release(struct file *filp) { 	struct rkvdec_ctx *ctx = file_to_rkvdec_ctx(filp); -	v4l2_fh_del(&ctx->fh);+	v4l2_fh_del(&ctx->fh, filp); 	v4l2_m2m_ctx_release(ctx->fh.m2m_ctx); 	v4l2_ctrl_handler_free(&ctx->ctrl_hdl); 	v4l2_fh_exit(&ctx->fh);diff --git a/drivers/media/platform/samsung/exynos-gsc/gsc-m2m.c b/drivers/media/platform/samsung/exynos-gsc/gsc-m2m.cindex 39d84ffd1b05..2999fb2610f0 100644--- a/drivers/media/platform/samsung/exynos-gsc/gsc-m2m.c+++ b/drivers/media/platform/samsung/exynos-gsc/gsc-m2m.c@@ -654,7 +654,7 @@ static int gsc_m2m_open(struct file *file)  error_ctrls: 	gsc_ctrls_delete(ctx);-	v4l2_fh_del(&ctx->fh);+	v4l2_fh_del(&ctx->fh, file); error_fh: 	v4l2_fh_exit(&ctx->fh); 	kfree(ctx);@@ -675,7 +675,7 @@ static int gsc_m2m_release(struct file *file)  	v4l2_m2m_ctx_release(ctx->m2m_ctx); 	gsc_ctrls_delete(ctx);-	v4l2_fh_del(&ctx->fh);+	v4l2_fh_del(&ctx->fh, file); 	v4l2_fh_exit(&ctx->fh);  	if (--gsc->m2m.refcnt <= 0)diff --git a/drivers/media/platform/samsung/exynos4-is/fimc-m2m.c b/drivers/media/platform/samsung/exynos4-is/fimc-m2m.cindex b002b02a899e..609fd84f89d4 100644--- a/drivers/media/platform/samsung/exynos4-is/fimc-m2m.c+++ b/drivers/media/platform/samsung/exynos4-is/fimc-m2m.c@@ -663,7 +663,7 @@ static int fimc_m2m_open(struct file *file) 	v4l2_m2m_ctx_release(ctx->fh.m2m_ctx); error_c: 	fimc_ctrls_delete(ctx);-	v4l2_fh_del(&ctx->fh);+	v4l2_fh_del(&ctx->fh, file); error_fh: 	v4l2_fh_exit(&ctx->fh); 	kfree(ctx);@@ -684,7 +684,7 @@ static int fimc_m2m_release(struct file *file)  	v4l2_m2m_ctx_release(ctx->fh.m2m_ctx); 	fimc_ctrls_delete(ctx);-	v4l2_fh_del(&ctx->fh);+	v4l2_fh_del(&ctx->fh, file); 	v4l2_fh_exit(&ctx->fh);  	if (--fimc->m2m.refcnt <= 0)diff --git a/drivers/media/platform/samsung/s5p-g2d/g2d.c b/drivers/media/platform/samsung/s5p-g2d/g2d.cindex e34cae9c9cf6..922262f61e7b 100644--- a/drivers/media/platform/samsung/s5p-g2d/g2d.c+++ b/drivers/media/platform/samsung/s5p-g2d/g2d.c@@ -280,7 +280,7 @@ static int g2d_release(struct file *file) 	v4l2_m2m_ctx_release(ctx->fh.m2m_ctx); 	mutex_unlock(&dev->mutex); 	v4l2_ctrl_handler_free(&ctx->ctrl_handler);-	v4l2_fh_del(&ctx->fh);+	v4l2_fh_del(&ctx->fh, file); 	v4l2_fh_exit(&ctx->fh); 	kfree(ctx); 	v4l2_info(&dev->v4l2_dev, "instance closed\n");diff --git a/drivers/media/platform/samsung/s5p-jpeg/jpeg-core.c b/drivers/media/platform/samsung/s5p-jpeg/jpeg-core.cindex 9e35dd939ad7..65f256db4c76 100644--- a/drivers/media/platform/samsung/s5p-jpeg/jpeg-core.c+++ b/drivers/media/platform/samsung/s5p-jpeg/jpeg-core.c@@ -1005,7 +1005,7 @@ static int s5p_jpeg_open(struct file *file) 	return 0;  error:-	v4l2_fh_del(&ctx->fh);+	v4l2_fh_del(&ctx->fh, file); 	v4l2_fh_exit(&ctx->fh); 	mutex_unlock(&jpeg->lock); free:@@ -1021,7 +1021,7 @@ static int s5p_jpeg_release(struct file *file) 	mutex_lock(&jpeg->lock); 	v4l2_m2m_ctx_release(ctx->fh.m2m_ctx); 	v4l2_ctrl_handler_free(&ctx->ctrl_handler);-	v4l2_fh_del(&ctx->fh);+	v4l2_fh_del(&ctx->fh, file); 	v4l2_fh_exit(&ctx->fh); 	kfree(ctx); 	mutex_unlock(&jpeg->lock);diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc.cindex 74629db05121..a5e756049620 100644--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c@@ -955,7 +955,7 @@ static int s5p_mfc_open(struct file *file) err_bad_node: 	dev->ctx[ctx->num] = NULL; err_no_ctx:-	v4l2_fh_del(&ctx->fh);+	v4l2_fh_del(&ctx->fh, file); 	v4l2_fh_exit(&ctx->fh); 	kfree(ctx); err_alloc:@@ -1010,7 +1010,7 @@ static int s5p_mfc_release(struct file *file) 	if (dev) 		dev->ctx[ctx->num] = NULL; 	s5p_mfc_dec_ctrls_delete(ctx);-	v4l2_fh_del(&ctx->fh);+	v4l2_fh_del(&ctx->fh, file); 	/* vdev is gone if dev is null */ 	if (dev) 		v4l2_fh_exit(&ctx->fh);diff --git a/drivers/media/platform/st/sti/bdisp/bdisp-v4l2.c b/drivers/media/platform/st/sti/bdisp/bdisp-v4l2.cindex 5e983799e298..38b2a2924443 100644--- a/drivers/media/platform/st/sti/bdisp/bdisp-v4l2.c+++ b/drivers/media/platform/st/sti/bdisp/bdisp-v4l2.c@@ -634,7 +634,7 @@ static int bdisp_open(struct file *file)  error_ctrls: 	bdisp_ctrls_delete(ctx);-	v4l2_fh_del(&ctx->fh);+	v4l2_fh_del(&ctx->fh, file); error_fh: 	v4l2_fh_exit(&ctx->fh); 	bdisp_hw_free_nodes(ctx);@@ -659,7 +659,7 @@ static int bdisp_release(struct file *file)  	bdisp_ctrls_delete(ctx); -	v4l2_fh_del(&ctx->fh);+	v4l2_fh_del(&ctx->fh, file); 	v4l2_fh_exit(&ctx->fh);  	if (--bdisp->m2m.refcnt <= 0)diff --git a/drivers/media/platform/st/sti/delta/delta-v4l2.c b/drivers/media/platform/st/sti/delta/delta-v4l2.cindex 3063a98ed25b..385b26d21408 100644--- a/drivers/media/platform/st/sti/delta/delta-v4l2.c+++ b/drivers/media/platform/st/sti/delta/delta-v4l2.c@@ -1684,7 +1684,7 @@ static int delta_open(struct file *file) 	return 0;  err_fh_del:-	v4l2_fh_del(&ctx->fh);+	v4l2_fh_del(&ctx->fh, file); 	v4l2_fh_exit(&ctx->fh); 	kfree(ctx); err:@@ -1712,7 +1712,7 @@ static int delta_release(struct file *file)  	v4l2_m2m_ctx_release(ctx->fh.m2m_ctx); -	v4l2_fh_del(&ctx->fh);+	v4l2_fh_del(&ctx->fh, file); 	v4l2_fh_exit(&ctx->fh);  	/* disable ST231 clocks */diff --git a/drivers/media/platform/st/sti/hva/hva-v4l2.c b/drivers/media/platform/st/sti/hva/hva-v4l2.cindex 2f9413fa7318..3581b73a99b8 100644--- a/drivers/media/platform/st/sti/hva/hva-v4l2.c+++ b/drivers/media/platform/st/sti/hva/hva-v4l2.c@@ -1218,7 +1218,7 @@ static int hva_open(struct file *file) err_ctrls: 	v4l2_ctrl_handler_free(&ctx->ctrl_handler); err_fh:-	v4l2_fh_del(&ctx->fh);+	v4l2_fh_del(&ctx->fh, file); 	v4l2_fh_exit(&ctx->fh); 	kfree(ctx); out:@@ -1249,7 +1249,7 @@ static int hva_release(struct file *file)  	v4l2_ctrl_handler_free(&ctx->ctrl_handler); -	v4l2_fh_del(&ctx->fh);+	v4l2_fh_del(&ctx->fh, file); 	v4l2_fh_exit(&ctx->fh);  #ifdef CONFIG_VIDEO_STI_HVA_DEBUGFSdiff --git a/drivers/media/platform/st/stm32/dma2d/dma2d.c b/drivers/media/platform/st/stm32/dma2d/dma2d.cindex b2bced06a1e6..bc0f81e78018 100644--- a/drivers/media/platform/st/stm32/dma2d/dma2d.c+++ b/drivers/media/platform/st/stm32/dma2d/dma2d.c@@ -326,7 +326,7 @@ static int dma2d_release(struct file *file) 	v4l2_m2m_ctx_release(ctx->fh.m2m_ctx); 	mutex_unlock(&dev->mutex); 	v4l2_ctrl_handler_free(&ctx->ctrl_handler);-	v4l2_fh_del(&ctx->fh);+	v4l2_fh_del(&ctx->fh, file); 	v4l2_fh_exit(&ctx->fh); 	kfree(ctx); diff --git a/drivers/media/platform/sunxi/sun8i-di/sun8i-di.c b/drivers/media/platform/sunxi/sun8i-di/sun8i-di.cindex 7823eb97faf7..eb519afb30ca 100644--- a/drivers/media/platform/sunxi/sun8i-di/sun8i-di.c+++ b/drivers/media/platform/sunxi/sun8i-di/sun8i-di.c@@ -759,7 +759,7 @@ static int deinterlace_release(struct file *file)  	mutex_lock(&dev->dev_mutex); -	v4l2_fh_del(&ctx->fh);+	v4l2_fh_del(&ctx->fh, file); 	v4l2_fh_exit(&ctx->fh); 	v4l2_m2m_ctx_release(ctx->fh.m2m_ctx); diff --git a/drivers/media/platform/sunxi/sun8i-rotate/sun8i_rotate.c b/drivers/media/platform/sunxi/sun8i-rotate/sun8i_rotate.cindex 368a858b8c0f..89992feaab60 100644--- a/drivers/media/platform/sunxi/sun8i-rotate/sun8i_rotate.c+++ b/drivers/media/platform/sunxi/sun8i-rotate/sun8i_rotate.c@@ -695,7 +695,7 @@ static int rotate_release(struct file *file) 	mutex_lock(&dev->dev_mutex);  	v4l2_ctrl_handler_free(&ctx->ctrl_handler);-	v4l2_fh_del(&ctx->fh);+	v4l2_fh_del(&ctx->fh, file); 	v4l2_fh_exit(&ctx->fh); 	v4l2_m2m_ctx_release(ctx->fh.m2m_ctx); diff --git a/drivers/media/platform/ti/omap3isp/ispvideo.c b/drivers/media/platform/ti/omap3isp/ispvideo.cindex d10a2b96c13c..2c0008444b7e 100644--- a/drivers/media/platform/ti/omap3isp/ispvideo.c+++ b/drivers/media/platform/ti/omap3isp/ispvideo.c@@ -1336,7 +1336,7 @@ static int isp_video_open(struct file *file)  done: 	if (ret < 0) {-		v4l2_fh_del(&handle->vfh);+		v4l2_fh_del(&handle->vfh, file); 		v4l2_fh_exit(&handle->vfh); 		kfree(handle); 	}@@ -1360,10 +1360,9 @@ static int isp_video_release(struct file *file) 	v4l2_pipeline_pm_put(&video->video.entity);  	/* Release the file handle. */-	v4l2_fh_del(vfh);+	v4l2_fh_del(vfh, file); 	v4l2_fh_exit(vfh); 	kfree(handle);-	file->private_data = NULL;  	omap3isp_put(video->isp); diff --git a/drivers/media/platform/ti/vpe/vpe.c b/drivers/media/platform/ti/vpe/vpe.cindex a47c5d31c475..6029d4e8e0bd 100644--- a/drivers/media/platform/ti/vpe/vpe.c+++ b/drivers/media/platform/ti/vpe/vpe.c@@ -2421,7 +2421,7 @@ static int vpe_release(struct file *file) 	vpdma_free_desc_buf(&ctx->sc_coeff_v); 	vpdma_free_desc_buf(&ctx->sc_coeff_h); -	v4l2_fh_del(&ctx->fh);+	v4l2_fh_del(&ctx->fh, file); 	v4l2_fh_exit(&ctx->fh); 	v4l2_ctrl_handler_free(&ctx->hdl); 	v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);diff --git a/drivers/media/platform/verisilicon/hantro_drv.c b/drivers/media/platform/verisilicon/hantro_drv.cindex aadc3d8fb3d1..4cc9d00fd293 100644--- a/drivers/media/platform/verisilicon/hantro_drv.c+++ b/drivers/media/platform/verisilicon/hantro_drv.c@@ -677,7 +677,7 @@ static int hantro_open(struct file *filp) 	return 0;  err_fh_free:-	v4l2_fh_del(&ctx->fh);+	v4l2_fh_del(&ctx->fh, filp); 	v4l2_fh_exit(&ctx->fh); err_ctx_free: 	kfree(ctx);@@ -693,7 +693,7 @@ static int hantro_release(struct file *filp) 	 * to this file. 	 */ 	v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);-	v4l2_fh_del(&ctx->fh);+	v4l2_fh_del(&ctx->fh, filp); 	v4l2_fh_exit(&ctx->fh); 	v4l2_ctrl_handler_free(&ctx->ctrl_handler); 	kfree(ctx);diff --git a/drivers/media/test-drivers/vicodec/vicodec-core.c b/drivers/media/test-drivers/vicodec/vicodec-core.cindex f20d9d9643f5..c340fd226040 100644--- a/drivers/media/test-drivers/vicodec/vicodec-core.c+++ b/drivers/media/test-drivers/vicodec/vicodec-core.c@@ -1946,7 +1946,7 @@ static int vicodec_release(struct file *file) 	mutex_lock(vfd->lock); 	v4l2_m2m_ctx_release(ctx->fh.m2m_ctx); 	mutex_unlock(vfd->lock);-	v4l2_fh_del(&ctx->fh);+	v4l2_fh_del(&ctx->fh, file); 	v4l2_fh_exit(&ctx->fh); 	v4l2_ctrl_handler_free(&ctx->hdl); 	kvfree(ctx->state.compressed_frame);diff --git a/drivers/media/test-drivers/vim2m.c b/drivers/media/test-drivers/vim2m.cindex 24574025f58f..d0e760118c82 100644--- a/drivers/media/test-drivers/vim2m.c+++ b/drivers/media/test-drivers/vim2m.c@@ -1450,7 +1450,7 @@ static int vim2m_release(struct file *file)  	dprintk(dev, 1, "Releasing instance %p\n", ctx); -	v4l2_fh_del(&ctx->fh);+	v4l2_fh_del(&ctx->fh, file); 	v4l2_fh_exit(&ctx->fh); 	v4l2_ctrl_handler_free(&ctx->hdl); 	mutex_lock(&dev->dev_mutex);diff --git a/drivers/media/test-drivers/visl/visl-core.c b/drivers/media/test-drivers/visl/visl-core.cindex 0f43ec23f40b..26c6c6835f79 100644--- a/drivers/media/test-drivers/visl/visl-core.c+++ b/drivers/media/test-drivers/visl/visl-core.c@@ -389,7 +389,7 @@ static int visl_release(struct file *file) 	dprintk(dev, "Releasing instance %p\n", ctx);  	tpg_free(&ctx->tpg);-	v4l2_fh_del(&ctx->fh);+	v4l2_fh_del(&ctx->fh, file); 	v4l2_fh_exit(&ctx->fh); 	v4l2_ctrl_handler_free(&ctx->hdl); 	mutex_lock(&dev->dev_mutex);diff --git a/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c b/drivers/media/usb/pvrusb2/pvrusb2-v4l2.cindex 04c77af0c51e..f9535a484738 100644--- a/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c+++ b/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c@@ -900,9 +900,8 @@ static int pvr2_v4l2_release(struct file *file) 		fhp->rhp = NULL; 	} -	v4l2_fh_del(&fhp->fh);+	v4l2_fh_del(&fhp->fh, file); 	v4l2_fh_exit(&fhp->fh);-	file->private_data = NULL;  	pvr2_channel_done(&fhp->channel); 	pvr2_trace(PVR2_TRACE_STRUCT,diff --git a/drivers/media/v4l2-core/v4l2-fh.c b/drivers/media/v4l2-core/v4l2-fh.cindex b59b1084d8cd..df3ba9d4674b 100644--- a/drivers/media/v4l2-core/v4l2-fh.c+++ b/drivers/media/v4l2-core/v4l2-fh.c@@ -67,7 +67,7 @@ int v4l2_fh_open(struct file *filp) } EXPORT_SYMBOL_GPL(v4l2_fh_open); -void v4l2_fh_del(struct v4l2_fh *fh)+void v4l2_fh_del(struct v4l2_fh *fh, struct file *filp) { 	unsigned long flags; @@ -75,6 +75,8 @@ void v4l2_fh_del(struct v4l2_fh *fh) 	list_del_init(&fh->list); 	spin_unlock_irqrestore(&fh->vdev->fh_lock, flags); 	v4l2_prio_close(fh->vdev->prio, fh->prio);++	filp->private_data = NULL; } EXPORT_SYMBOL_GPL(v4l2_fh_del); @@ -94,10 +96,9 @@ int v4l2_fh_release(struct file *filp) 	struct v4l2_fh *fh = file_to_v4l2_fh(filp);  	if (fh) {-		v4l2_fh_del(fh);+		v4l2_fh_del(fh, filp); 		v4l2_fh_exit(fh); 		kfree(fh);-		filp->private_data = NULL; 	} 	return 0; }diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.cindex bf35ac436249..41e4aca77b7f 100644--- a/drivers/media/v4l2-core/v4l2-subdev.c+++ b/drivers/media/v4l2-core/v4l2-subdev.c@@ -109,7 +109,7 @@ static int subdev_open(struct file *file)  err: 	module_put(subdev_fh->owner);-	v4l2_fh_del(&subdev_fh->vfh);+	v4l2_fh_del(&subdev_fh->vfh, file); 	v4l2_fh_exit(&subdev_fh->vfh); 	subdev_fh_free(subdev_fh); 	kfree(subdev_fh);@@ -127,11 +127,10 @@ static int subdev_close(struct file *file) 	if (sd->internal_ops && sd->internal_ops->close) 		sd->internal_ops->close(sd, subdev_fh); 	module_put(subdev_fh->owner);-	v4l2_fh_del(vfh);+	v4l2_fh_del(vfh, file); 	v4l2_fh_exit(vfh); 	subdev_fh_free(subdev_fh); 	kfree(subdev_fh);-	file->private_data = NULL;  	return 0; }diff --git a/drivers/staging/media/imx/imx-media-csc-scaler.c b/drivers/staging/media/imx/imx-media-csc-scaler.cindex 7fedb33dda34..dc7f9a77cbe6 100644--- a/drivers/staging/media/imx/imx-media-csc-scaler.c+++ b/drivers/staging/media/imx/imx-media-csc-scaler.c@@ -792,7 +792,7 @@ static int ipu_csc_scaler_open(struct file *file) err_ctrls: 	v4l2_m2m_ctx_release(ctx->fh.m2m_ctx); err_ctx:-	v4l2_fh_del(&ctx->fh);+	v4l2_fh_del(&ctx->fh, file); 	v4l2_fh_exit(&ctx->fh); 	kfree(ctx); 	return ret;@@ -807,7 +807,7 @@ static int ipu_csc_scaler_release(struct file *file)  	v4l2_ctrl_handler_free(&ctx->ctrl_hdlr); 	v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);-	v4l2_fh_del(&ctx->fh);+	v4l2_fh_del(&ctx->fh, file); 	v4l2_fh_exit(&ctx->fh); 	kfree(ctx); diff --git a/drivers/staging/media/meson/vdec/vdec.c b/drivers/staging/media/meson/vdec/vdec.cindex b92666ff50a1..49e497a32973 100644--- a/drivers/staging/media/meson/vdec/vdec.c+++ b/drivers/staging/media/meson/vdec/vdec.c@@ -926,7 +926,7 @@ static int vdec_close(struct file *file)  	v4l2_m2m_ctx_release(sess->m2m_ctx); 	v4l2_m2m_release(sess->m2m_dev);-	v4l2_fh_del(&sess->fh);+	v4l2_fh_del(&sess->fh, file); 	v4l2_fh_exit(&sess->fh);  	mutex_destroy(&sess->lock);diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.c b/drivers/staging/media/sunxi/cedrus/cedrus.cindex ebefd646dbdb..bff42ea1871f 100644--- a/drivers/staging/media/sunxi/cedrus/cedrus.c+++ b/drivers/staging/media/sunxi/cedrus/cedrus.c@@ -404,7 +404,7 @@ static int cedrus_release(struct file *file)  	mutex_lock(&dev->dev_mutex); -	v4l2_fh_del(&ctx->fh);+	v4l2_fh_del(&ctx->fh, file); 	v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);  	v4l2_ctrl_handler_free(&ctx->hdl);diff --git a/drivers/staging/most/video/video.c b/drivers/staging/most/video/video.cindex 24a68e3e5419..32f71d9a9cf7 100644--- a/drivers/staging/most/video/video.c+++ b/drivers/staging/most/video/video.c@@ -107,7 +107,7 @@ static int comp_vdev_open(struct file *filp) 	return 0;  err_rm:-	v4l2_fh_del(&fh->fh);+	v4l2_fh_del(&fh->fh, filp); 	v4l2_fh_exit(&fh->fh);  err_dec:@@ -143,7 +143,7 @@ static int comp_vdev_close(struct file *filp) 	most_stop_channel(mdev->iface, mdev->ch_idx, &comp); 	mdev->mute = false; -	v4l2_fh_del(&fh->fh);+	v4l2_fh_del(&fh->fh, filp); 	v4l2_fh_exit(&fh->fh);  	atomic_dec(&mdev->access_ref);diff --git a/drivers/usb/gadget/function/uvc_v4l2.c b/drivers/usb/gadget/function/uvc_v4l2.cindex 680f25d17dc2..fd4b998ccd16 100644--- a/drivers/usb/gadget/function/uvc_v4l2.c+++ b/drivers/usb/gadget/function/uvc_v4l2.c@@ -692,8 +692,7 @@ uvc_v4l2_release(struct file *file) 		uvc_v4l2_disable(uvc); 	mutex_unlock(&video->mutex); -	file->private_data = NULL;-	v4l2_fh_del(&handle->vfh);+	v4l2_fh_del(&handle->vfh, file); 	v4l2_fh_exit(&handle->vfh); 	kfree(handle); diff --git a/include/media/v4l2-fh.h b/include/media/v4l2-fh.hindex d8fcf49f10e0..5e4c76163512 100644--- a/include/media/v4l2-fh.h+++ b/include/media/v4l2-fh.h@@ -114,12 +114,15 @@ int v4l2_fh_open(struct file *filp);  * v4l2_fh_del - Remove file handle from the list of file handles.  *  * @fh: pointer to &struct v4l2_fh+ * @filp: pointer to &struct file associated with @fh+ *+ * The function resets filp->private_data to NULL.  *  * .. note::  *    Must be called in v4l2_file_operations->release\(\) handler if the driver  *    uses &struct v4l2_fh.  */-void v4l2_fh_del(struct v4l2_fh *fh);+void v4l2_fh_del(struct v4l2_fh *fh, struct file *filp);  /**  * v4l2_fh_exit - Release resources related to a file handle.-- Regards, Laurent Pinchart