mirror of
https://github.com/torvalds/linux.git
synced 2026-06-05 04:56:13 +02:00
media: vidtv: mux: Add check and kfree for kstrdup
[ Upstream commit1fd6eb1264] 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:c2f78f0cb2("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>
This commit is contained in:
parent
a51335704a
commit
aae7598aff
|
|
@ -504,13 +504,16 @@ struct vidtv_mux *vidtv_mux_init(struct dvb_frontend *fe,
|
|||
m->priv = args->priv;
|
||||
m->network_id = args->network_id;
|
||||
m->network_name = kstrdup(args->network_name, GFP_KERNEL);
|
||||
if (!m->network_name)
|
||||
goto free_mux_buf;
|
||||
|
||||
m->timing.current_jiffies = get_jiffies_64();
|
||||
|
||||
if (args->channels)
|
||||
m->channels = args->channels;
|
||||
else
|
||||
if (vidtv_channels_init(m) < 0)
|
||||
goto free_mux_buf;
|
||||
goto free_mux_network_name;
|
||||
|
||||
/* will alloc data for pmt_sections after initializing pat */
|
||||
if (vidtv_channel_si_init(m) < 0)
|
||||
|
|
@ -527,6 +530,8 @@ struct vidtv_mux *vidtv_mux_init(struct dvb_frontend *fe,
|
|||
vidtv_channel_si_destroy(m);
|
||||
free_channels:
|
||||
vidtv_channels_destroy(m);
|
||||
free_mux_network_name:
|
||||
kfree(m->network_name);
|
||||
free_mux_buf:
|
||||
vfree(m->mux_buf);
|
||||
free_mux:
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user