diff options
author | Hans Verkuil <hverkuil-cisco@xs4all.nl> | 2021-09-14 09:21:25 +0200 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab+huawei@kernel.org> | 2021-10-19 09:08:19 +0200 |
commit | 112024a3b6dcfc62ec36ea0cf58b897f2ce54c59 (patch) | |
tree | e312ca26b8a4a90ae9530875e00cb5264b793f2a /drivers/media | |
parent | media: cedrus: fix double free (diff) | |
download | linux-112024a3b6dcfc62ec36ea0cf58b897f2ce54c59.tar.xz linux-112024a3b6dcfc62ec36ea0cf58b897f2ce54c59.zip |
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>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/test-drivers/vidtv/vidtv_bridge.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/media/test-drivers/vidtv/vidtv_bridge.c b/drivers/media/test-drivers/vidtv/vidtv_bridge.c index 0f6d998d18dc..82620613d56b 100644 --- a/drivers/media/test-drivers/vidtv/vidtv_bridge.c +++ b/drivers/media/test-drivers/vidtv/vidtv_bridge.c @@ -557,7 +557,6 @@ static int vidtv_bridge_remove(struct platform_device *pdev) dvb_dmxdev_release(&dvb->dmx_dev); dvb_dmx_release(&dvb->demux); dvb_unregister_adapter(&dvb->adapter); - kfree(dvb); dev_info(&pdev->dev, "Successfully removed vidtv\n"); return 0; @@ -565,6 +564,10 @@ static int vidtv_bridge_remove(struct platform_device *pdev) static void vidtv_bridge_dev_release(struct device *dev) { + struct vidtv_dvb *dvb; + + dvb = dev_get_drvdata(dev); + kfree(dvb); } static struct platform_device vidtv_bridge_dev = { |