[dpdk-dev] net/qede: fix resource leak

Message ID 1480509129-27623-1-git-send-email-wang.yong19@zte.com.cn (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers

Checks

Context Check Description
checkpatch/checkpatch success coding style OK

Commit Message

Yong Wang Nov. 30, 2016, 12:32 p.m. UTC
  Current code does not close 'fd' on function exit, leaking resources.

Signed-off-by: Yong Wang <wang.yong19@zte.com.cn>
---
 drivers/net/qede/qede_main.c | 3 +++
 1 file changed, 3 insertions(+)
  

Comments

Ferruh Yigit Dec. 8, 2016, 4:52 p.m. UTC | #1
On 11/30/2016 12:32 PM, Yong Wang wrote:
> Current code does not close 'fd' on function exit, leaking resources.
> 
> Signed-off-by: Yong Wang <wang.yong19@zte.com.cn>
> ---

Add new mail address of the maintainer.

CC: Harish Patil <harish.patil@cavium.com>

<...>
  
Harish Patil Dec. 12, 2016, 7:32 p.m. UTC | #2
>On 11/30/2016 12:32 PM, Yong Wang wrote:

>> Current code does not close 'fd' on function exit, leaking resources.

>> 

>> Signed-off-by: Yong Wang <wang.yong19@zte.com.cn>

>> ---

>

>Add new mail address of the maintainer.

>

>CC: Harish Patil <harish.patil@cavium.com>

>

><...>

>


Acked-by: Harish Patil <harish.patil@qlogic.com>
  
Ferruh Yigit Dec. 13, 2016, 11:51 a.m. UTC | #3
On 12/12/2016 7:32 PM, Harish Patil wrote:
> 
>> On 11/30/2016 12:32 PM, Yong Wang wrote:
>>> Current code does not close 'fd' on function exit, leaking resources.
>>>
>>> Signed-off-by: Yong Wang <wang.yong19@zte.com.cn>
>>> ---
>>
>> Add new mail address of the maintainer.
>>
>> CC: Harish Patil <harish.patil@cavium.com>
>>
>> <...>
>>
> 
> Acked-by: Harish Patil <harish.patil@qlogic.com>
> 

Applied to dpdk-next-net/master, thanks.
  
Ferruh Yigit Dec. 13, 2016, 11:52 a.m. UTC | #4
On 11/30/2016 12:32 PM, Yong Wang wrote:
> Current code does not close 'fd' on function exit, leaking resources.
> 
> Signed-off-by: Yong Wang <wang.yong19@zte.com.cn>

CC: stable@dpdk.org

> ---
>  drivers/net/qede/qede_main.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/net/qede/qede_main.c b/drivers/net/qede/qede_main.c
> index ab22409..b666e1c 100644
> --- a/drivers/net/qede/qede_main.c
> +++ b/drivers/net/qede/qede_main.c
> @@ -137,6 +137,7 @@ static int qed_load_firmware_data(struct ecore_dev *edev)
>  
>  	if (fstat(fd, &st) < 0) {
>  		DP_NOTICE(edev, false, "Can't stat firmware file\n");
> +		close(fd);
>  		return -1;
>  	}
>  
> @@ -158,9 +159,11 @@ static int qed_load_firmware_data(struct ecore_dev *edev)
>  	if (edev->fw_len < 104) {
>  		DP_NOTICE(edev, false, "Invalid fw size: %" PRIu64 "\n",
>  			  edev->fw_len);
> +		close(fd);
>  		return -EINVAL;
>  	}
>  
> +	close(fd);
>  	return 0;
>  }
>  #endif
>
  

Patch

diff --git a/drivers/net/qede/qede_main.c b/drivers/net/qede/qede_main.c
index ab22409..b666e1c 100644
--- a/drivers/net/qede/qede_main.c
+++ b/drivers/net/qede/qede_main.c
@@ -137,6 +137,7 @@  static int qed_load_firmware_data(struct ecore_dev *edev)
 
 	if (fstat(fd, &st) < 0) {
 		DP_NOTICE(edev, false, "Can't stat firmware file\n");
+		close(fd);
 		return -1;
 	}
 
@@ -158,9 +159,11 @@  static int qed_load_firmware_data(struct ecore_dev *edev)
 	if (edev->fw_len < 104) {
 		DP_NOTICE(edev, false, "Invalid fw size: %" PRIu64 "\n",
 			  edev->fw_len);
+		close(fd);
 		return -EINVAL;
 	}
 
+	close(fd);
 	return 0;
 }
 #endif