Skip to content

Commit

Permalink
net/virtio-user: fix devargs parsing
Browse files Browse the repository at this point in the history
[ upstream commit bc5b6c1 ]

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: ce2eabd ("net/virtio-user: add virtual device")

Signed-off-by: Ivan Dyukov <i.dyukov@samsung.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
  • Loading branch information
Ivan Dyukov authored and kevintraynor committed May 27, 2020
1 parent 6b0addc commit faf078d
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions drivers/net/virtio/virtio_user_ethdev.c
Expand Up @@ -388,12 +388,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 *
Expand Down

0 comments on commit faf078d

Please sign in to comment.