patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-stable] [PATCH] net/failsafe: fix exec parameter parsing error flow
@ 2017-08-29 14:59 Matan Azrad
  2017-08-29 16:33 ` Gaëtan Rivet
  2017-08-30 15:59 ` [dpdk-stable] [PATCH] net/failsafe: fix errno set on command execution Gaetan Rivet
  0 siblings, 2 replies; 7+ messages in thread
From: Matan Azrad @ 2017-08-29 14:59 UTC (permalink / raw)
  To: Gaetan Rivet; +Cc: dev, Raslan Darawsheh, stable

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

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

end of thread, other threads:[~2017-09-01 15:59 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-29 14:59 [dpdk-stable] [PATCH] net/failsafe: fix exec parameter parsing error flow Matan Azrad
2017-08-29 16:33 ` 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 ` [dpdk-stable] [PATCH] net/failsafe: fix errno set on command execution Gaetan Rivet
2017-09-01 15:59   ` Ferruh Yigit

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).