DPDK patches and discussions
 help / color / mirror / Atom feed
From: Kuba Kozak <kubax.kozak@intel.com>
To: konstantin.ananyev@intel.com
Cc: dev@dpdk.org, Kuba Kozak <kubax.kozak@intel.com>, stable@dpdk.org
Subject: [dpdk-dev] [PATCH] l3fwd-acl: fix unchecked return value
Date: Tue,  3 Oct 2017 13:48:02 +0200	[thread overview]
Message-ID: <1507031282-12469-1-git-send-email-kubax.kozak@intel.com> (raw)

Add return value check and error handling for fseek call.

Coverity issue: 143435
Fixes: 361b2e9559fc ("acl: new sample l3fwd-acl")
Cc: konstantin.ananyev@intel.com
Cc: stable@dpdk.org

Signed-off-by: Kuba Kozak <kubax.kozak@intel.com>
Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
---
 examples/l3fwd-acl/main.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/examples/l3fwd-acl/main.c b/examples/l3fwd-acl/main.c
index 8eff4de..708e9eb 100644
--- a/examples/l3fwd-acl/main.c
+++ b/examples/l3fwd-acl/main.c
@@ -1026,6 +1026,7 @@ add_rules(const char *rule_path,
 	char buff[LINE_MAX];
 	FILE *fh = fopen(rule_path, "rb");
 	unsigned int i = 0;
+	int val;
 
 	if (fh == NULL)
 		rte_exit(EXIT_FAILURE, "%s: Open %s failed\n", __func__,
@@ -1042,7 +1043,11 @@ add_rules(const char *rule_path,
 		rte_exit(EXIT_FAILURE, "Not find any route entries in %s!\n",
 				rule_path);
 
-	fseek(fh, 0, SEEK_SET);
+	val = fseek(fh, 0, SEEK_SET);
+	if (val < 0) {
+		rte_exit(EXIT_FAILURE, "%s: File seek operation failed\n",
+			__func__);
+	}
 
 	acl_rules = calloc(acl_num, rule_size);
 
-- 
2.7.4

             reply	other threads:[~2017-10-03 11:52 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-03 11:48 Kuba Kozak [this message]
2017-10-10  6:55 ` Yang, Zhiyong
2017-10-11  6:58   ` Kozak, KubaX
2017-10-11  7:07     ` Yang, Zhiyong
2017-10-13 22:43       ` [dpdk-dev] [dpdk-stable] " Thomas Monjalon
2017-10-13 22:41 ` Thomas Monjalon

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=1507031282-12469-1-git-send-email-kubax.kozak@intel.com \
    --to=kubax.kozak@intel.com \
    --cc=dev@dpdk.org \
    --cc=konstantin.ananyev@intel.com \
    --cc=stable@dpdk.org \
    /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).