patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Ivan Dyukov <i.dyukov@samsung.com>
To: dev@dpdk.org, maxime.coquelin@redhat.com, i.dyukov@samsung.com,
	v.kuramshin@samsung.com, amorenoz@redhat.com,
	zhihong.wang@intel.com, xiaolong.ye@intel.com,
	mb@smartsharesystems.com
Cc: stable@dpdk.org
Subject: [dpdk-stable] [PATCH v11 4/6] net/virtio-user: fix devargs parsing
Date: Thu, 16 Apr 2020 08:53:04 +0300	[thread overview]
Message-ID: <20200416055309.19679-5-i.dyukov@samsung.com> (raw)
In-Reply-To: <20200416055309.19679-1-i.dyukov@samsung.com>

strtoull returns 0 if it fails to parse input string. It's ignored
in get_integer_arg.

This patch handles error cases for strtoull function.

Fixes: ce2eabdd43ec ("net/virtio-user: add virtual device")
Cc: stable@dpdk.org
Signed-off-by: Ivan Dyukov <i.dyukov@samsung.com>
---
 drivers/net/virtio/virtio_user_ethdev.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/net/virtio/virtio_user_ethdev.c b/drivers/net/virtio/virtio_user_ethdev.c
index e61af4068..a79f68a36 100644
--- a/drivers/net/virtio/virtio_user_ethdev.c
+++ b/drivers/net/virtio/virtio_user_ethdev.c
@@ -477,12 +477,17 @@ static int
 get_integer_arg(const char *key __rte_unused,
 		const char *value, void *extra_args)
 {
+	uint64_t integer = 0;
 	if (!value || !extra_args)
 		return -EINVAL;
-
-	*(uint64_t *)extra_args = strtoull(value, NULL, 0);
-
-	return 0;
+	errno = 0;
+	integer = strtoull(value, NULL, 0);
+	/* extra_args keeps default value, it should be replaced
+	 * only in case of successful parsing of the 'value' arg
+	 */
+	if (errno == 0)
+		*(uint64_t *)extra_args = integer;
+	return -errno;
 }
 
 static struct rte_eth_dev *
-- 
2.17.1


  parent reply	other threads:[~2020-04-16  5:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20191212085012.9170-1-i.dyukov@samsung.com>
     [not found] ` <20200406085855.25773-1-i.dyukov@samsung.com>
     [not found]   ` <CGME20200406085918eucas1p200d058b72ac3e35b61dd1a119b9fcb55@eucas1p2.samsung.com>
     [not found]     ` <20200406085855.25773-4-i.dyukov@samsung.com>
2020-04-15 15:09       ` [dpdk-stable] [PATCH v9 3/5] " Maxime Coquelin
     [not found] ` <20200415200423.6410-1-i.dyukov@samsung.com>
     [not found]   ` <CGME20200415200445eucas1p2406d3f5b1794958c8345741c83d2000e@eucas1p2.samsung.com>
2020-04-15 20:03     ` [dpdk-stable] [PATCH v10 4/6] " Ivan Dyukov
     [not found] ` <20200416055309.19679-1-i.dyukov@samsung.com>
     [not found]   ` <CGME20200416055330eucas1p120bee1af98e108e09dd7515faf094c73@eucas1p1.samsung.com>
2020-04-16  5:53     ` Ivan Dyukov [this message]
     [not found] ` <20200416124258.15549-1-i.dyukov@samsung.com>
     [not found]   ` <CGME20200416124317eucas1p15276ceb13bfb49ba429e4391d1ecce53@eucas1p1.samsung.com>
2020-04-16 12:42     ` [dpdk-stable] [PATCH v12 5/7] " Ivan Dyukov

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=20200416055309.19679-5-i.dyukov@samsung.com \
    --to=i.dyukov@samsung.com \
    --cc=amorenoz@redhat.com \
    --cc=dev@dpdk.org \
    --cc=maxime.coquelin@redhat.com \
    --cc=mb@smartsharesystems.com \
    --cc=stable@dpdk.org \
    --cc=v.kuramshin@samsung.com \
    --cc=xiaolong.ye@intel.com \
    --cc=zhihong.wang@intel.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).