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)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Tue, 19 Oct 2021 07:08:19 +0000 (08:08 +0100)
commit112024a3b6dcfc62ec36ea0cf58b897f2ce54c59
treee312ca26b8a4a90ae9530875e00cb5264b793f2a
parentfe47b6d7582ad1a608d8341c3e02c3e06f5678e6
media: vidtv: move kfree(dvb) to vidtv_bridge_dev_release()

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>
drivers/media/test-drivers/vidtv/vidtv_bridge.c