]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
media: em28xx: fix memory leak
authorMuhammad Usama Anjum <musamaanjum@gmail.com>
Wed, 24 Mar 2021 18:07:53 +0000 (19:07 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 22 May 2021 08:59:17 +0000 (10:59 +0200)
[ Upstream commit 0ae10a7dc8992ee682ff0b1752ff7c83d472eef1 ]

If some error occurs, URB buffers should also be freed. If they aren't
freed with the dvb here, the em28xx_dvb_fini call doesn't frees the URB
buffers as dvb is set to NULL. The function in which error occurs should
do all the cleanup for the allocations it had done.

Tested the patch with the reproducer provided by syzbot. This patch
fixes the memleak.

Reported-by: syzbot+889397c820fa56adf25d@syzkaller.appspotmail.com
Signed-off-by: Muhammad Usama Anjum <musamaanjum@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/media/usb/em28xx/em28xx-dvb.c

index a73faf12f7e471c17a300003efdc969852cc2c07..e1946237ac8cd509fe3de094a0259ff32979af74 100644 (file)
@@ -1924,6 +1924,7 @@ ret:
        return result;
 
 out_free:
+       em28xx_uninit_usb_xfer(dev, EM28XX_DIGITAL_MODE);
        kfree(dvb);
        dev->dvb = NULL;
        goto ret;