]> git.ipfire.org Git - thirdparty/linux.git/commit
media: pci: ivtv: Don't create fake v4l2_fh
authorLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Sun, 10 Aug 2025 01:29:54 +0000 (04:29 +0300)
committerHans Verkuil <hverkuil+cisco@kernel.org>
Wed, 13 Aug 2025 06:33:31 +0000 (08:33 +0200)
commitcc6e8d1ccea792d8550428e0831e3a35b0ccfddc
tree2d8bb76de57c867d1f9b424f51f99a11a7028fa7
parent4416df03ddf28566bb7c0169d9bd1e696d567899
media: pci: ivtv: Don't create fake v4l2_fh

The ivtv driver has a structure named ivtv_open_id that models an open
file handle for the device. It embeds a v4l2_fh instance for file
handles that correspond to a V4L2 video device, and stores a pointer to
that v4l2_fh in struct ivtv_stream to identify which open file handle
owns a particular stream.

In addition to video devices, streams can be owned by ALSA PCM devices.
Those devices do not make use of the v4l2_fh instance for obvious
reasons, but the snd_ivtv_pcm_capture_open() function still initializes
a "fake" v4l2_fh for the sole purpose of using it as an open file handle
identifier. The v4l2_fh is not properly destroyed when the ALSA PCM
device is closed, leading to possible resource leaks.

Fortunately, the v4l2_fh instance pointed to by ivtv_stream is not
accessed, only the pointer value is used for comparison. Replace it with
a pointer to the ivtv_open_id structure that embeds the v4l2_fh, and
don't initialize the v4l2_fh for ALSA PCM devices.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
drivers/media/pci/ivtv/ivtv-alsa-pcm.c
drivers/media/pci/ivtv/ivtv-driver.h
drivers/media/pci/ivtv/ivtv-fileops.c
drivers/media/pci/ivtv/ivtv-irq.c