fpga: region: release FPGA region reference in error path

If fpga_region_get_manager() fails in fpga_region_program_fpga(), a
reference to the fpga_manager instance previously acquired through
fpga_region_get() is retained. Make sure to properly release it in the
error case by using a separate jump label which will call
fpga_region_put() in before returning.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Acked-by: Moritz Fischer <mdf@kernel.org>
Signed-off-by: Alan Tull <atull@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Tobias Klauser 2017-04-24 16:34:21 -05:00 committed by Greg Kroah-Hartman
parent d721f9bbe6
commit e73bbf6490
1 changed files with 3 additions and 1 deletions

View File

@ -245,7 +245,8 @@ static int fpga_region_program_fpga(struct fpga_region *region,
mgr = fpga_region_get_manager(region);
if (IS_ERR(mgr)) {
pr_err("failed to get fpga region manager\n");
return PTR_ERR(mgr);
ret = PTR_ERR(mgr);
goto err_put_region;
}
ret = fpga_region_get_bridges(region, overlay);
@ -281,6 +282,7 @@ static int fpga_region_program_fpga(struct fpga_region *region,
fpga_bridges_put(&region->bridge_list);
err_put_mgr:
fpga_mgr_put(mgr);
err_put_region:
fpga_region_put(region);
return ret;