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)
committerHans Verkuil <hverkuil-cisco@xs4all.nl>
Sat, 7 Oct 2023 08:55:45 +0000 (10:55 +0200)
commit1fd6eb12642e0c32692924ff359c07de4b781d78
tree0e87b26dc209c8a789ada6fcf3215ba201d5bdb3
parent76a2c5df6ca8bd8ada45e953b8c72b746f42918d
media: vidtv: mux: Add check and kfree for kstrdup

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>
drivers/media/test-drivers/vidtv/vidtv_mux.c