media: vidtv: mux: Add check and kfree for kstrdup
authorJiasheng Jiang <jiasheng@iscas.ac.cn>
Mon, 19 Jun 2023 08:12:02 +0000 (16:12 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 20 Nov 2023 10:59:32 +0000 (11:59 +0100)
commitaae7598aff291d4d140be1355aa20930af948785
treee85f45fa302a90ee65a8b72a82d34caf0c988216
parenta51335704a3f90eaf23a6864faefca34b382490a
media: vidtv: mux: Add check and kfree for kstrdup

[ Upstream commit 1fd6eb12642e0c32692924ff359c07de4b781d78 ]

Add check for the return value of kstrdup() and return the error
if it fails in order to avoid NULL pointer dereference.
Moreover, use kfree() in the later error handling in order to avoid
memory leak.

Fixes: c2f78f0cb294 ("media: vidtv: psi: add a Network Information Table (NIT)")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/media/test-drivers/vidtv/vidtv_mux.c