Skip to content

Commit

Permalink
media: pci: cx23885: handle adding to list failure
Browse files Browse the repository at this point in the history
[ Upstream commit c5d5952 ]

altera_hw_filt_init() which calls append_internal() assumes
that the node was successfully linked in while in fact it can
silently fail. So the call-site needs to set return to -ENOMEM
on append_internal() returning NULL and exit through the err path.

Fixes: 349bcf0 ("[media] Altera FPGA based CI driver module")

Signed-off-by: Nicholas Mc Guire <[email protected]>
Signed-off-by: Hans Verkuil <[email protected]>
Signed-off-by: Mauro Carvalho Chehab <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
Nicholas Mc Guire authored and gregkh committed Nov 22, 2018
1 parent 62d3277 commit 2eb6603
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions drivers/media/pci/cx23885/altera-ci.c
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,10 @@ static int altera_hw_filt_init(struct altera_ci_config *config, int hw_filt_nr)
}

temp_int = append_internal(inter);
if (!temp_int) {
ret = -ENOMEM;
goto err;
}
inter->filts_used = 1;
inter->dev = config->dev;
inter->fpga_rw = config->fpga_rw;
Expand Down Expand Up @@ -696,6 +700,7 @@ static int altera_hw_filt_init(struct altera_ci_config *config, int hw_filt_nr)
__func__, ret);

kfree(pid_filt);
kfree(inter);

return ret;
}
Expand Down Expand Up @@ -731,6 +736,10 @@ int altera_ci_init(struct altera_ci_config *config, int ci_nr)
}

temp_int = append_internal(inter);
if (!temp_int) {
ret = -ENOMEM;
goto err;
}
inter->cis_used = 1;
inter->dev = config->dev;
inter->fpga_rw = config->fpga_rw;
Expand Down Expand Up @@ -799,6 +808,7 @@ int altera_ci_init(struct altera_ci_config *config, int ci_nr)
ci_dbg_print("%s: Cannot initialize CI: Error %d.\n", __func__, ret);

kfree(state);
kfree(inter);

return ret;
}
Expand Down

0 comments on commit 2eb6603

Please sign in to comment.