Skip to content

Commit b3ad2c5

Browse files
Nicholas Mc Guiregregkh
authored andcommitted
media: pci: cx23885: handle adding to list failure
[ 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 <hofrat@osadl.org> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 85c2f31 commit b3ad2c5

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

‎drivers/media/pci/cx23885/altera-ci.c‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,10 @@ static int altera_hw_filt_init(struct altera_ci_config *config, int hw_filt_nr)
665665
}
666666

667667
temp_int = append_internal(inter);
668+
if (!temp_int) {
669+
ret = -ENOMEM;
670+
goto err;
671+
}
668672
inter->filts_used = 1;
669673
inter->dev = config->dev;
670674
inter->fpga_rw = config->fpga_rw;
@@ -699,6 +703,7 @@ static int altera_hw_filt_init(struct altera_ci_config *config, int hw_filt_nr)
699703
__func__, ret);
700704

701705
kfree(pid_filt);
706+
kfree(inter);
702707

703708
return ret;
704709
}
@@ -733,6 +738,10 @@ int altera_ci_init(struct altera_ci_config *config, int ci_nr)
733738
}
734739

735740
temp_int = append_internal(inter);
741+
if (!temp_int) {
742+
ret = -ENOMEM;
743+
goto err;
744+
}
736745
inter->cis_used = 1;
737746
inter->dev = config->dev;
738747
inter->fpga_rw = config->fpga_rw;
@@ -801,6 +810,7 @@ int altera_ci_init(struct altera_ci_config *config, int ci_nr)
801810
ci_dbg_print("%s: Cannot initialize CI: Error %d.\n", __func__, ret);
802811

803812
kfree(state);
813+
kfree(inter);
804814

805815
return ret;
806816
}

0 commit comments

Comments
 (0)