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>
Wed, 17 Nov 2021 10:04:51 +0000 (11:04 +0100)
commit4f2bf4fe6c0d4100763753fb7bb2635ee96825a6
tree2b34913d8c148b89aa973ab753fc5c8da24cbbd6
parentaf09862cb5661cfdedd114ae50c7aaed94bd185a
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