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:40:09 +0000 (14:40 +0200)
commit663e7a72871f89f7a10cc8d7b2f17f27c64e071d
treeca9d16ba216d7b6e34be220493c12b699e57c551
parent4d68603cc4382174bc1e7d532e10675c48c6b257
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