]> git.baikalelectronics.ru Git - kernel.git/commit
media: em28xx: fix memory leak in em28xx_init_dev
authorDongliang Mu <mudongliangabcd@gmail.com>
Mon, 1 Nov 2021 09:55:39 +0000 (09:55 +0000)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Mon, 15 Nov 2021 08:12:02 +0000 (08:12 +0000)
commit33c949496fb851f6f095901990458315fb137779
tree028606e178608e4f04a542c0218306169210927b
parent19353046660d6dc5c2b844c8389101bea73d2084
media: em28xx: fix memory leak in em28xx_init_dev

In the em28xx_init_rev, if em28xx_audio_setup fails, this function fails
to deallocate the media_dev allocated in the em28xx_media_device_init.

Fix this by adding em28xx_unregister_media_device to free media_dev.

BTW, this patch is tested in my local syzkaller instance, and it can
prevent the memory leak from occurring again.

CC: Pavel Skripkin <paskripkin@gmail.com>
Fixes: 0da299ac5364 ("[media] em28xx: add media controller support")
Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com>
Reported-by: syzkaller <syzkaller@googlegroups.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/media/usb/em28xx/em28xx-cards.c