]> Gentwo Git Trees - linux/.git/commit
media: Reset file->private_data to NULL in v4l2_fh_del()
authorLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Sun, 10 Aug 2025 01:30:09 +0000 (04:30 +0300)
committerHans Verkuil <hverkuil+cisco@kernel.org>
Wed, 13 Aug 2025 06:33:44 +0000 (08:33 +0200)
commit277966749f46bc6292c4052b4e66a554f193a78a
treeb40124ca8f234907e24097c03c81e51e42cca8df
parent47f4b1acb4d505b1e7e81d8e0ebce774422b8c2e
media: Reset file->private_data to NULL in v4l2_fh_del()

Multiple drivers that use v4l2_fh and call v4l2_fh_del() manually reset
the file->private_data pointer to NULL in their video device .release()
file operation handler. Move the code to the v4l2_fh_del() function to
avoid direct access to file->private_data in drivers. This requires
adding a file pointer argument to the function.

Changes to drivers have been generated with the following coccinelle
semantic 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 usage
patterns, to drivers/media/v4l2-core/v4l2-fh.c to update the
v4l2_fh_del() prototype and reset file->private_data, and to
include/media/v4l2-fh.h to update the v4l2_fh_del() function prototype
and its documentation.

Additionally, white space issues have been fixed manually in
drivers/usb/gadget/function/uvc_v4l2.c

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
57 files changed:
Documentation/driver-api/media/v4l2-fh.rst
Documentation/translations/zh_CN/video4linux/v4l2-framework.txt
drivers/media/pci/cx18/cx18-fileops.c
drivers/media/pci/ivtv/ivtv-fileops.c
drivers/media/pci/saa7164/saa7164-encoder.c
drivers/media/pci/saa7164/saa7164-vbi.c
drivers/media/platform/allegro-dvt/allegro-core.c
drivers/media/platform/amlogic/meson-ge2d/ge2d.c
drivers/media/platform/amphion/vpu_v4l2.c
drivers/media/platform/chips-media/coda/coda-common.c
drivers/media/platform/chips-media/wave5/wave5-helper.c
drivers/media/platform/imagination/e5010-jpeg-enc.c
drivers/media/platform/m2m-deinterlace.c
drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c
drivers/media/platform/mediatek/mdp/mtk_mdp_m2m.c
drivers/media/platform/mediatek/mdp3/mtk-mdp3-m2m.c
drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c
drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc_drv.c
drivers/media/platform/nvidia/tegra-vde/v4l2.c
drivers/media/platform/nxp/dw100/dw100.c
drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c
drivers/media/platform/nxp/imx-pxp.c
drivers/media/platform/nxp/imx8-isi/imx8-isi-m2m.c
drivers/media/platform/nxp/mx2_emmaprp.c
drivers/media/platform/qcom/iris/iris_vidc.c
drivers/media/platform/qcom/venus/core.c
drivers/media/platform/renesas/rcar_fdp1.c
drivers/media/platform/renesas/rcar_jpu.c
drivers/media/platform/renesas/vsp1/vsp1_video.c
drivers/media/platform/rockchip/rga/rga.c
drivers/media/platform/rockchip/rkvdec/rkvdec.c
drivers/media/platform/samsung/exynos-gsc/gsc-m2m.c
drivers/media/platform/samsung/exynos4-is/fimc-m2m.c
drivers/media/platform/samsung/s5p-g2d/g2d.c
drivers/media/platform/samsung/s5p-jpeg/jpeg-core.c
drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c
drivers/media/platform/st/sti/bdisp/bdisp-v4l2.c
drivers/media/platform/st/sti/delta/delta-v4l2.c
drivers/media/platform/st/sti/hva/hva-v4l2.c
drivers/media/platform/st/stm32/dma2d/dma2d.c
drivers/media/platform/sunxi/sun8i-di/sun8i-di.c
drivers/media/platform/sunxi/sun8i-rotate/sun8i_rotate.c
drivers/media/platform/ti/omap3isp/ispvideo.c
drivers/media/platform/ti/vpe/vpe.c
drivers/media/platform/verisilicon/hantro_drv.c
drivers/media/test-drivers/vicodec/vicodec-core.c
drivers/media/test-drivers/vim2m.c
drivers/media/test-drivers/visl/visl-core.c
drivers/media/usb/pvrusb2/pvrusb2-v4l2.c
drivers/media/v4l2-core/v4l2-fh.c
drivers/media/v4l2-core/v4l2-subdev.c
drivers/staging/media/imx/imx-media-csc-scaler.c
drivers/staging/media/meson/vdec/vdec.c
drivers/staging/media/sunxi/cedrus/cedrus.c
drivers/staging/most/video/video.c
drivers/usb/gadget/function/uvc_v4l2.c
include/media/v4l2-fh.h