media: vidtv: move kfree(dvb) to vidtv_bridge_dev_release()
authorHans Verkuil <hverkuil-cisco@xs4all.nl>
Tue, 14 Sep 2021 07:21:25 +0000 (08:21 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 18 Nov 2021 18:17:20 +0000 (19:17 +0100)
commit855eba695ddc400955064ec5ffcb1bae65c9b615
tree110a88ecf8f51993d347123123e77cfb679996e3
parentbb7e50b476abb8fc94a9891bb7f08ab21801fec5
media: vidtv: move kfree(dvb) to vidtv_bridge_dev_release()

commit 112024a3b6dcfc62ec36ea0cf58b897f2ce54c59 upstream.

Adding kfree(dvb) to vidtv_bridge_remove() will remove the memory
too soon: if an application still has an open filehandle to the device
when the driver is unloaded, then when that filehandle is closed, a
use-after-free access takes place to the freed memory.

Move the kfree(dvb) to vidtv_bridge_dev_release() instead.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Fixes: 76e21bb8be4f ("media: vidtv: Fix memory leak in remove")
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/media/test-drivers/vidtv/vidtv_bridge.c