All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matan Azrad <matan@mellanox.com>
To: Gaetan Rivet <gaetan.rivet@6wind.com>
Cc: dev@dpdk.org, Raslan Darawsheh <rasland@mellanox.com>, stable@dpdk.org
Subject: [PATCH] net/failsafe: fix exec parameter parsing error flow
Date: Tue, 29 Aug 2017 17:59:08 +0300	[thread overview]
Message-ID: <1504018748-4766-1-git-send-email-matan@mellanox.com> (raw)

The corrupted code returns success value in case of the
execution process output stream is empty(EOF).
It causes to segmentation fault while failsafe polls
this command line again, than gets success and tries to
do hotplug add to the sub device by uninitialized pointer
dereferencing.

Morever, when the output is not empty but uncorrect, failsafe
returns error for its probe function while the expected
behavior is to do polling until the output is correct.

The fix changes the return value to be -ENODEV for this
sub device in the two cases.
By this way, failsafe tries to parse this sub device parameter
by exec method until the output is correct.

Fixes: a0194d828100 ("net/failsafe: add flexible device definition")
Fixes: 35ffe4208140 ("net/failsafe: fix missing pclose after popen")
Cc: stable@dpdk.org

Signed-off-by: Matan Azrad <matan@mellanox.com>
---
 drivers/net/failsafe/failsafe_args.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/net/failsafe/failsafe_args.c b/drivers/net/failsafe/failsafe_args.c
index 645c885..61c55df 100644
--- a/drivers/net/failsafe/failsafe_args.c
+++ b/drivers/net/failsafe/failsafe_args.c
@@ -157,12 +157,16 @@ fs_execute_cmd(struct sub_device *sdev, char *cmdline)
 	ret = fs_parse_device(sdev, output);
 	if (ret) {
 		ERROR("Parsing device '%s' failed", output);
+		ret = -ENODEV;
 		goto ret_pclose;
 	}
 ret_pclose:
 	pclose_ret = pclose(fp);
 	if (pclose_ret) {
-		pclose_ret = errno;
+		if (errno == 0)
+			errno = -(pclose_ret = ret);
+		else
+			pclose_ret = errno;
 		ERROR("pclose: %s", strerror(errno));
 		errno = old_err;
 		return pclose_ret;
-- 
2.7.4

             reply	other threads:[~2017-08-29 14:59 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-29 14:59 Matan Azrad [this message]
2017-08-29 16:33 ` [PATCH] net/failsafe: fix exec parameter parsing error flow Gaëtan Rivet
2017-08-30  6:11   ` Matan Azrad
2017-08-30 14:24     ` Gaëtan Rivet
2017-08-30 15:32       ` Matan Azrad
2017-08-30 15:59 ` [PATCH] net/failsafe: fix errno set on command execution Gaetan Rivet
2017-09-01 15:59   ` [dpdk-stable] " 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=1504018748-4766-1-git-send-email-matan@mellanox.com \
    --to=matan@mellanox.com \
    --cc=dev@dpdk.org \
    --cc=gaetan.rivet@6wind.com \
    --cc=rasland@mellanox.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 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.