linux/drivers/staging/most
Laurent Pinchart 277966749f 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>
2025-08-13 08:33:44 +02:00
..
Documentation staging: most: Documentation: move ABI description files out of staging area 2020-03-24 13:42:44 +01:00
dim2 staging: Switch back to struct platform_driver::remove() 2024-10-09 11:54:53 +02:00
i2c staging: most: i2c: Drop explicit initialization of struct i2c_device_id::driver_data to 0 2024-10-09 11:54:47 +02:00
net staging: most: net: Make use of the helper macro LIST_HEAD() 2022-02-15 17:05:34 +01:00
video media: Reset file->private_data to NULL in v4l2_fh_del() 2025-08-13 08:33:44 +02:00
Kconfig drivers: most: add ALSA sound driver 2021-03-23 10:03:13 +01:00
Makefile drivers: most: add ALSA sound driver 2021-03-23 10:03:13 +01:00
TODO staging: most: Remove TODO contact information 2024-11-10 08:03:31 +01:00