* Re: [PATCH] fpga: region: release FPGA region reference in error path
[not found] <20170410135103.18612-1-tklauser@distanz.ch>
@ 2017-04-10 17:56 ` Moritz Fischer
2017-04-10 18:50 ` Alan Tull
0 siblings, 1 reply; 2+ messages in thread
From: Moritz Fischer @ 2017-04-10 17:56 UTC (permalink / raw)
To: Tobias Klauser; +Cc: Alan Tull, Moritz Fischer, linux-fpga
[-- Attachment #1: Type: text/plain, Size: 1416 bytes --]
On Mon, Apr 10, 2017 at 03:51:03PM +0200, Tobias Klauser wrote:
> 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>
> ---
> 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 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(®ion->bridge_list);
> err_put_mgr:
> fpga_mgr_put(mgr);
> +err_put_region:
> fpga_region_put(region);
>
> return ret;
> --
> 2.12.2
>
>
Thanks,
Moritz
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] fpga: region: release FPGA region reference in error path
2017-04-10 17:56 ` [PATCH] fpga: region: release FPGA region reference in error path Moritz Fischer
@ 2017-04-10 18:50 ` Alan Tull
0 siblings, 0 replies; 2+ messages in thread
From: Alan Tull @ 2017-04-10 18:50 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Tobias Klauser, Moritz Fischer, linux-fpga, Moritz Fischer, linux-kernel
On Mon, Apr 10, 2017 at 12:56 PM, Moritz Fischer <mdf@kernel.org> wrote:
> On Mon, Apr 10, 2017 at 03:51:03PM +0200, Tobias Klauser wrote:
>> 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 --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(®ion->bridge_list);
>> err_put_mgr:
>> fpga_mgr_put(mgr);
>> +err_put_region:
>> fpga_region_put(region);
>>
>> return ret;
>> --
>> 2.12.2
>>
>>
>
> Thanks,
> Moritz
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-04-10 18:51 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20170410135103.18612-1-tklauser@distanz.ch>
2017-04-10 17:56 ` [PATCH] fpga: region: release FPGA region reference in error path Moritz Fischer
2017-04-10 18:50 ` Alan Tull
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.