mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] fpga manager: Fix firmware resource leak on error
@ 2015-11-18  9:48 Tobias Klauser
  2015-11-18 15:23 ` atull
  0 siblings, 1 reply; 2+ messages in thread
From: Tobias Klauser @ 2015-11-18  9:48 UTC (permalink / raw)
  To: Alan Tull; +Cc: Greg Kroah-Hartman, Moritz Fischer, linux-kernel

If fpga_mgr_buf_load() fails, the firmware resource previously allocated
by request_firmware() is leaked. Fix it by calling release_firmware()
regardless of the return value of fpga_mgr_buf_load().

Found by the Coverity scanner (CID 1339653).

Fixes: 6a8c3be7ec8e ("add FPGA manager core")
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
---
 drivers/fpga/fpga-mgr.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c
index a24f5cb877e0..aad6439c3692 100644
--- a/drivers/fpga/fpga-mgr.c
+++ b/drivers/fpga/fpga-mgr.c
@@ -122,12 +122,10 @@ int fpga_mgr_firmware_load(struct fpga_manager *mgr, u32 flags,
 	}
 
 	ret = fpga_mgr_buf_load(mgr, flags, fw->data, fw->size);
-	if (ret)
-		return ret;
 
 	release_firmware(fw);
 
-	return 0;
+	return ret;
 }
 EXPORT_SYMBOL_GPL(fpga_mgr_firmware_load);
 
-- 
2.6.3.368.gf34be46.dirty



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] fpga manager: Fix firmware resource leak on error
  2015-11-18  9:48 [PATCH] fpga manager: Fix firmware resource leak on error Tobias Klauser
@ 2015-11-18 15:23 ` atull
  0 siblings, 0 replies; 2+ messages in thread
From: atull @ 2015-11-18 15:23 UTC (permalink / raw)
  To: Tobias Klauser; +Cc: Greg Kroah-Hartman, Moritz Fischer, linux-kernel

On Wed, 18 Nov 2015, Tobias Klauser wrote:

> If fpga_mgr_buf_load() fails, the firmware resource previously allocated
> by request_firmware() is leaked. Fix it by calling release_firmware()
> regardless of the return value of fpga_mgr_buf_load().
> 
> Found by the Coverity scanner (CID 1339653).
> 
> Fixes: 6a8c3be7ec8e ("add FPGA manager core")
> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
> ---
>  drivers/fpga/fpga-mgr.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c
> index a24f5cb877e0..aad6439c3692 100644
> --- a/drivers/fpga/fpga-mgr.c
> +++ b/drivers/fpga/fpga-mgr.c
> @@ -122,12 +122,10 @@ int fpga_mgr_firmware_load(struct fpga_manager *mgr, u32 flags,
>  	}
>  
>  	ret = fpga_mgr_buf_load(mgr, flags, fw->data, fw->size);
> -	if (ret)
> -		return ret;
>  
>  	release_firmware(fw);
>  
> -	return 0;
> +	return ret;
>  }
>  EXPORT_SYMBOL_GPL(fpga_mgr_firmware_load);
>  
> -- 
> 2.6.3.368.gf34be46.dirty
> 
> 
> 

Thanks Tobias!

Acked-by: Alan Tull <atull@opensource.altera.com>

Alan


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-11-18 15:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-18  9:48 [PATCH] fpga manager: Fix firmware resource leak on error Tobias Klauser
2015-11-18 15:23 ` atull

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®