diff mbox

[2/3] fpga: region: release FPGA region reference in error path

Message ID 20170424213422.3190-3-atull@kernel.org (mailing list archive)
State Accepted, archived
Headers show

Commit Message

Alan Tull April 24, 2017, 9:34 p.m. UTC
From: Tobias Klauser <tklauser@distanz.ch>

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>
 drivers/fpga/fpga-region.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff mbox


diff --git a/drivers/fpga/fpga-region.c b/drivers/fpga/fpga-region.c
index ae4c61a..3b6b2f4 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 @@  static int fpga_region_program_fpga(struct fpga_region *region,
 	return ret;