From: Tobias Klauser Date: Mon, 24 Apr 2017 21:34:21 +0000 (-0500) Subject: fpga: region: release FPGA region reference in error path X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=e73bbf64907c88d3bb811756fc25548131524035;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git 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 Acked-by: Moritz Fischer Signed-off-by: Alan Tull Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/fpga/fpga-region.c b/drivers/fpga/fpga-region.c index ae4c61aada99..3b6b2f4182a1 100644 --- a/drivers/fpga/fpga-region.c +++ b/drivers/fpga/fpga-region.c @@ -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 @@ err_put_br: fpga_bridges_put(®ion->bridge_list); err_put_mgr: fpga_mgr_put(mgr); +err_put_region: fpga_region_put(region); return ret;