[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20170424213422.3190-3-atull@kernel.org>
Date: Mon, 24 Apr 2017 16:34:21 -0500
From: Alan Tull <atull@...nel.org>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: Moritz Fischer <moritz.fischer@...us.com>,
Alan Tull <atull@...nel.org>, linux-kernel@...r.kernel.org,
linux-fpga@...r.kernel.org, Tobias Klauser <tklauser@...tanz.ch>
Subject: [PATCH 2/3] fpga: region: release FPGA region reference in error path
From: Tobias Klauser <tklauser@...tanz.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@...tanz.ch>
Acked-by: Moritz Fischer <mdf@...nel.org>
Signed-off-by: Alan Tull <atull@...nel.org>
---
drivers/fpga/fpga-region.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
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,
fpga_bridges_put(®ion->bridge_list);
err_put_mgr:
fpga_mgr_put(mgr);
+err_put_region:
fpga_region_put(region);
return ret;
--
2.7.4
Powered by blists - more mailing lists