media: media/saa7164: fix saa7164_encoder_register() memory leak bugs
authorDaniel Niv <danielniv3@gmail.com>
Thu, 11 Mar 2021 02:53:00 +0000 (03:53 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 11 May 2021 12:47:24 +0000 (14:47 +0200)
commit6a3edc1a5e1792aecea910283601b64d3a426728
tree404ab21397d8eaeecaa7d9c370b1e4f1cfe20843
parent087c2bffb4e92ae31dae38744be217e1d17ae639
media: media/saa7164: fix saa7164_encoder_register() memory leak bugs

[ Upstream commit c759b2970c561e3b56aa030deb13db104262adfe ]

Add a fix for the memory leak bugs that can occur when the
saa7164_encoder_register() function fails.
The function allocates memory without explicitly freeing
it when errors occur.
Add a better error handling that deallocate the unused buffers before the
function exits during a fail.

Signed-off-by: Daniel Niv <danielniv3@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/pci/saa7164/saa7164-encoder.c