diff mbox

fpga: region: Fix some error handling

Message ID 20170427091345.a6vpeapnesey7k6d@mwanda (mailing list archive)
State Superseded, archived
Headers show

Commit Message

Dan Carpenter April 27, 2017, 9:13 a.m. UTC
We need to release some resources if fpga_region_get_manager() fails.

Fixes: 0fa20cdfcc1f ("fpga: fpga-region: device tree control for FPGA")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

--
To unsubscribe from this list: send the line "unsubscribe linux-fpga" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Alan Tull April 27, 2017, 2:34 p.m. UTC | #1
On Thu, Apr 27, 2017 at 4:13 AM, Dan Carpenter <dan.carpenter@oracle.com> wrote:

Hi Dan,

Thanks but this fix is already in linux-next:

https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit?id=e73bbf64907c88d3bb811756fc25548131524035

Alan

> We need to release some resources if fpga_region_get_manager() fails.
>
> Fixes: 0fa20cdfcc1f ("fpga: fpga-region: device tree control for FPGA")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> 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 @@ 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;
--
To unsubscribe from this list: send the line "unsubscribe linux-fpga" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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 @@  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;