media: vidtv: Check for null return of vzalloc
authorJiasheng Jiang <jiasheng@iscas.ac.cn>
Fri, 14 Jan 2022 06:28:40 +0000 (07:28 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 8 Apr 2022 12:23:20 +0000 (14:23 +0200)
commit9dd2fd7a1f84c947561af29424c5ddcecfcf2cbe
tree57e2c0edb9a4efdbbc2560c6b1d2d61f9f7c01d0
parenta09e9882800fdfc5aab93f77c3f0132071d2191b
media: vidtv: Check for null return of vzalloc

[ Upstream commit e6a21a14106d9718aa4f8e115b1e474888eeba44 ]

As the possible failure of the vzalloc(), e->encoder_buf might be NULL.
Therefore, it should be better to check it in order
to guarantee the success of the initialization.
If fails, we need to free not only 'e' but also 'e->name'.
Also, if the allocation for ctx fails, we need to free 'e->encoder_buf'
else.

Fixes: f90cf6079bf6 ("media: vidtv: add a bridge driver")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/media/test-drivers/vidtv/vidtv_s302m.c