DPDK patches and discussions
 help / color / mirror / Atom feed
From: Yong Wang <wang.yong19@zte.com.cn>
To: harish.patil@qlogic.com
Cc: dev@dpdk.org, Yong Wang <wang.yong19@zte.com.cn>
Subject: [dpdk-dev] [PATCH] net/qede: fix resource leak
Date: Wed, 30 Nov 2016 07:32:09 -0500	[thread overview]
Message-ID: <1480509129-27623-1-git-send-email-wang.yong19@zte.com.cn> (raw)

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(+)

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
-- 
1.8.3.1

             reply	other threads:[~2016-11-30 11:32 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-30 12:32 Yong Wang [this message]
2016-12-08 16:52 ` Ferruh Yigit
2016-12-12 19:32   ` Harish Patil
2016-12-13 11:51     ` Ferruh Yigit
2016-12-13 11:52 ` Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1480509129-27623-1-git-send-email-wang.yong19@zte.com.cn \
    --to=wang.yong19@zte.com.cn \
    --cc=dev@dpdk.org \
    --cc=harish.patil@qlogic.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).